* src/vipw.c: Report failures to remove files to stderr.
* src/vipw.c: Report failures to unlock files to stderr.
This commit is contained in:
parent
e3e99974f8
commit
10e78fbd8e
@ -1,3 +1,8 @@
|
|||||||
|
2008-08-07 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* src/vipw.c: Report failures to remove files to stderr.
|
||||||
|
* src/vipw.c: Report failures to unlock files to stderr.
|
||||||
|
|
||||||
2008-08-07 Nicolas François <nicolas.francois@centraliens.net>
|
2008-08-07 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* NEWS, src/groupmems.c: Added syslog support.
|
* NEWS, src/groupmems.c: Added syslog support.
|
||||||
|
25
src/vipw.c
25
src/vipw.c
@ -62,7 +62,7 @@ static bool quiet = false;
|
|||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void usage (void);
|
static void usage (void);
|
||||||
static int create_backup_file (FILE *, const char *, struct stat *);
|
static int create_backup_file (FILE *, const char *, struct stat *);
|
||||||
static void vipwexit (const char *, int, int);
|
static void vipwexit (const char *msg, int syserr, int ret);
|
||||||
static void vipwedit (const char *, int (*)(void), int (*)(void));
|
static void vipwedit (const char *, int (*)(void), int (*)(void));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -136,10 +136,16 @@ static void vipwexit (const char *msg, int syserr, int ret)
|
|||||||
int err = errno;
|
int err = errno;
|
||||||
|
|
||||||
if (createedit) {
|
if (createedit) {
|
||||||
unlink (fileeditname);
|
if (unlink (fileeditname) != 0) {
|
||||||
|
fprintf (stderr, _("%s: failed to remove %s\n"), progname, fileeditname);
|
||||||
|
/* continue */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (filelocked) {
|
if (filelocked) {
|
||||||
(*unlock) ();
|
if ((*unlock) () == 0) {
|
||||||
|
fprintf (stderr, _("%s: failed to unlock %s\n"), progname, fileeditname);
|
||||||
|
/* continue */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (NULL != msg) {
|
if (NULL != msg) {
|
||||||
fprintf (stderr, "%s: %s", progname, msg);
|
fprintf (stderr, "%s: %s", progname, msg);
|
||||||
@ -147,8 +153,9 @@ static void vipwexit (const char *msg, int syserr, int ret)
|
|||||||
if (0 != syserr) {
|
if (0 != syserr) {
|
||||||
fprintf (stderr, ": %s", strerror (err));
|
fprintf (stderr, ": %s", strerror (err));
|
||||||
}
|
}
|
||||||
|
(void) fputs ("\n", stderr);
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
fprintf (stdout, _("\n%s: %s is unchanged\n"), progname,
|
fprintf (stdout, _("%s: %s is unchanged\n"), progname,
|
||||||
filename);
|
filename);
|
||||||
}
|
}
|
||||||
exit (ret);
|
exit (ret);
|
||||||
@ -262,13 +269,15 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
|
|||||||
link (file, filebackup);
|
link (file, filebackup);
|
||||||
if (rename (fileedit, file) == -1) {
|
if (rename (fileedit, file) == -1) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_
|
_("%s: can't restore %s: %s (your changes are in %s)\n"),
|
||||||
("%s: can't restore %s: %s (your changes are in %s)\n"),
|
progname, file, strerror (errno), fileedit);
|
||||||
progname, file, strerror (errno), fileedit);
|
|
||||||
vipwexit (0, 0, 1);
|
vipwexit (0, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
(*file_unlock) ();
|
if ((*file_unlock) () == 0) {
|
||||||
|
fprintf (stderr, _("%s: failed to unlock %s\n"), progname, fileeditname);
|
||||||
|
/* continue */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
|
Loading…
Reference in New Issue
Block a user