int main(int argc, char *argv[])
{
- int c, fd;
+ int c, fd = -1;
struct stat st;
static const struct option longopts[] = {
{ "help", 0, NULL, 'h' },
}
fd = open(_PATH_NOLOGIN_TXT, O_RDONLY);
+ if (fd < 0)
+ goto dflt;
+
c = fstat(fd, &st);
- if (fd >= 0 && !c && S_ISREG(st.st_mode)) {
+ if (c < 0 || !S_ISREG(st.st_mode))
+ goto dflt;
+ else {
char buf[BUFSIZ];
ssize_t rd;
while ((rd = read(fd, buf, sizeof(buf))) > 0)
ignore_result( write(STDOUT_FILENO, buf, rd) );
+
close(fd);
- } else
- fprintf(stdout, _("This account is currently not available.\n"));
+ return EXIT_FAILURE;
+ }
+dflt:
+ if (fd >= 0)
+ close(fd);
+ fprintf(stdout, _("This account is currently not available.\n"));
return EXIT_FAILURE;
}