2 * Copyright (C) 2013 Karel Zak <kzak@redhat.com>
16 #include "pathnames.h"
19 * Always return EXIT_FAILURE (1), don't try to be smart!
22 static void __attribute__((__noreturn__
)) usage(void)
25 fputs(USAGE_HEADER
, out
);
27 _(" %s [options]\n"), program_invocation_short_name
);
29 fputs(USAGE_SEPARATOR
, out
);
30 fputs(_("Politely refuse a login.\n"), out
);
32 fputs(USAGE_OPTIONS
, out
);
33 fputs(_(" -c, --command <command> does nothing (for compatibility with su -c)\n"), out
);
34 printf(USAGE_HELP_OPTIONS(26));
36 printf(USAGE_MAN_TAIL("nologin(8)"));
40 int main(int argc
, char *argv
[])
45 OPT_INIT_FILE
= CHAR_MAX
+ 1,
51 static const struct option longopts
[] = {
52 { "command", required_argument
, NULL
, 'c' },
53 { "init-file", required_argument
, NULL
, OPT_INIT_FILE
},
54 { "interactive", no_argument
, NULL
, 'i' },
55 { "login", no_argument
, NULL
, 'l' },
56 { "noprofile", no_argument
, NULL
, OPT_NOPROFILE
},
57 { "norc", no_argument
, NULL
, OPT_NORC
},
58 { "posix", no_argument
, NULL
, OPT_POSIX
},
59 { "rcfile", required_argument
, NULL
, OPT_RCFILE
},
60 { "restricted", no_argument
, NULL
, 'r' },
61 { "help", no_argument
, NULL
, 'h' },
62 { "version", no_argument
, NULL
, 'V' },
66 setlocale(LC_ALL
, "");
67 bindtextdomain(PACKAGE
, LOCALEDIR
);
70 while ((c
= getopt_long(argc
, argv
, "c:ilrhV", longopts
, NULL
)) != -1) {
81 /* Ignore well known shell command-line options */
86 print_version(EXIT_FAILURE
); /* yes FAILURE! */
88 errtryhelp(EXIT_FAILURE
);
92 fd
= open(_PATH_NOLOGIN_TXT
, O_RDONLY
);
97 if (c
< 0 || !S_ISREG(st
.st_mode
))
103 while ((rd
= read(fd
, buf
, sizeof(buf
))) > 0)
104 ignore_result( write(STDOUT_FILENO
, buf
, rd
) );
113 fprintf(stdout
, _("This account is currently not available.\n"));