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