2 * Copyright (C) 2013 Karel Zak <kzak@redhat.com>
16 #include "pathnames.h"
17 #include "fileutils.h"
20 * Always return EXIT_FAILURE (1), don't try to be smart!
23 static void __attribute__((__noreturn__
)) usage(void)
26 fputs(USAGE_HEADER
, out
);
28 _(" %s [options]\n"), program_invocation_short_name
);
30 fputs(USAGE_SEPARATOR
, out
);
31 fputs(_("Politely refuse a login.\n"), out
);
33 fputs(USAGE_OPTIONS
, out
);
34 fputs(_(" -c, --command <command> does nothing (for compatibility with su -c)\n"), out
);
35 fprintf(out
, USAGE_HELP_OPTIONS(26));
37 fprintf(out
, USAGE_MAN_TAIL("nologin(8)"));
41 int main(int argc
, char *argv
[])
46 OPT_INIT_FILE
= CHAR_MAX
+ 1,
52 static const struct option longopts
[] = {
53 { "command", required_argument
, NULL
, 'c' },
54 { "init-file", required_argument
, NULL
, OPT_INIT_FILE
},
55 { "interactive", no_argument
, NULL
, 'i' },
56 { "login", no_argument
, NULL
, 'l' },
57 { "noprofile", no_argument
, NULL
, OPT_NOPROFILE
},
58 { "norc", no_argument
, NULL
, OPT_NORC
},
59 { "posix", no_argument
, NULL
, OPT_POSIX
},
60 { "rcfile", required_argument
, NULL
, OPT_RCFILE
},
61 { "restricted", no_argument
, NULL
, 'r' },
62 { "help", no_argument
, NULL
, 'h' },
63 { "version", no_argument
, NULL
, 'V' },
67 setlocale(LC_ALL
, "");
68 bindtextdomain(PACKAGE
, LOCALEDIR
);
71 while ((c
= getopt_long(argc
, argv
, "c:ilrhV", longopts
, NULL
)) != -1) {
82 /* Ignore well known shell command-line options */
87 print_version(EXIT_FAILURE
); /* yes FAILURE! */
89 errtryhelp(EXIT_FAILURE
);
93 fd
= open(_PATH_NOLOGIN_TXT
, O_RDONLY
);
98 if (c
< 0 || !S_ISREG(st
.st_mode
))
101 ul_copy_file(fd
, STDOUT_FILENO
);
109 fprintf(stdout
, _("This account is currently not available.\n"));