login-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
c05a80ca63
commit
439cdf1e24
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "c.h"
|
||||
#include "env.h"
|
||||
#include "closestream.h"
|
||||
#include "islocal.h"
|
||||
#include "nls.h"
|
||||
#include "pamfail.h"
|
||||
|
@ -96,6 +97,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, ""); /* both for messages and for iscntrl() below */
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
/*
|
||||
* "oldf" contains the users original finger information.
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "c.h"
|
||||
#include "env.h"
|
||||
#include "closestream.h"
|
||||
#include "islocal.h"
|
||||
#include "nls.h"
|
||||
#include "pamfail.h"
|
||||
|
@ -82,6 +83,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
uid = getuid();
|
||||
memset(&info, 0, sizeof(info));
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "closestream.h"
|
||||
#include "islocal.h"
|
||||
#include "nls.h"
|
||||
#include "pathnames.h"
|
||||
|
@ -94,6 +95,7 @@ int is_local(const char *user)
|
|||
#ifdef TEST_PROGRAM
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
atexit(close_stdout);
|
||||
if (argc <= 2) {
|
||||
fprintf(stderr, "usage: %s <passwdfile> <username> [...]\n",
|
||||
argv[0]);
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "closestream.h"
|
||||
#include "pathnames.h"
|
||||
#include "nls.h"
|
||||
#include "xalloc.h"
|
||||
|
@ -121,6 +122,7 @@ main(int argc, char **argv) {
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((ch = getopt(argc, argv, "0123456789yli:f:h:t:")) != -1)
|
||||
switch((char)ch) {
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <sys/syslog.h>
|
||||
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
#include "logindefs.h"
|
||||
#include "nls.h"
|
||||
#include "pathnames.h"
|
||||
|
@ -252,6 +253,7 @@ int logindefs_setenv(const char *name, const char *conf, const char *dflt)
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *name, *type;
|
||||
atexit(close_stdout);
|
||||
|
||||
if (argc <= 1)
|
||||
errx(EXIT_FAILURE, "usage: %s <filename> "
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#endif
|
||||
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
#include "nls.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
|
@ -132,6 +133,7 @@ int main(int argc, char *argv[])
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((ch = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1)
|
||||
switch (ch) {
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "c.h"
|
||||
#include "fileutils.h"
|
||||
#include "closestream.h"
|
||||
#include "setpwnam.h"
|
||||
|
||||
static void pw_init(void);
|
||||
|
@ -143,9 +143,7 @@ int setpwnam(struct passwd *pwd)
|
|||
/* xfmkstemp is too restrictive by default for passwd file */
|
||||
if (fchmod(fileno(fp), 0644) < 0)
|
||||
goto fail;
|
||||
rc = fclose(fp);
|
||||
fp = NULL;
|
||||
if (rc < 0)
|
||||
if (close_stream(fp) != 0)
|
||||
goto fail;
|
||||
|
||||
fclose(pwf); /* I don't think I want to know if this failed */
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#endif
|
||||
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
#include "nls.h"
|
||||
#include "pathnames.h"
|
||||
#include "strutils.h"
|
||||
|
@ -476,6 +477,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
/*
|
||||
* See if we have a timeout flag.
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "c.h"
|
||||
#include "fileutils.h"
|
||||
#include "closestream.h"
|
||||
#include "nls.h"
|
||||
#include "setpwnam.h"
|
||||
#include "strutils.h"
|
||||
|
@ -283,7 +283,8 @@ static void edit_file(int is_shadow)
|
|||
ch_ret = fchmod(fileno(tmp_fd), 0400);
|
||||
if (ch_ret < 0)
|
||||
err(EXIT_FAILURE, "%s: %s", _("cannot chmod file"), orig_file);
|
||||
fclose(tmp_fd);
|
||||
if (close_stream(tmp_fd) != 0)
|
||||
err(EXIT_FAILURE, _("write error"));
|
||||
pw_write();
|
||||
close(passwd_file);
|
||||
ulckpwdf();
|
||||
|
@ -294,6 +295,7 @@ int main(int argc, char *argv[])
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
if (!strcmp(program_invocation_short_name, "vigr")) {
|
||||
program = VIGR;
|
||||
|
|
Loading…
Reference in New Issue