Avoid defining own macros which could be toggled with DEBUG.
Also add backup passwd file suffix to pathnames.h.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
#define _PATH_GROUP "/etc/group"
#define _PATH_SHADOW_PASSWD "/etc/shadow"
#define _PATH_SHELLS "/etc/shells"
+#define _PATH_PASSWDBAK_SUFFIX "-"
#ifndef _PATH_TMP
# define _PATH_TMP "/tmp/"
#include "closestream.h"
#include "islocal.h"
#include "nls.h"
+#include "pathnames.h"
#include "setpwnam.h"
#include "strutils.h"
#include "xalloc.h"
#include "c.h"
#include "fileutils.h"
#include "closestream.h"
+#include "pathnames.h"
#include "setpwnam.h"
static void pw_init(void);
if (lckpwdf() < 0)
goto fail;
locked = 1;
- pwf = fopen(PASSWD_FILE, "r");
+ pwf = fopen(_PATH_PASSWD, "r");
if (!pwf)
goto fail;
}
/* we don't care if we can't remove the backup file */
- unlink(PASSWD_FILE "-");
+ unlink(_PATH_PASSWD _PATH_PASSWDBAK_SUFFIX);
/* we don't care if we can't create the backup file */
- ignore_result(link(PASSWD_FILE, PASSWD_FILE "-"));
+ ignore_result(link(_PATH_PASSWD, _PATH_PASSWD _PATH_PASSWDBAK_SUFFIX));
/* we DO care if we can't rename to the passwd file */
- if (rename(tmpname, PASSWD_FILE) < 0)
+ if (rename(tmpname, _PATH_PASSWD) < 0)
goto fail;
/* finally: success */
ulckpwdf();
#ifndef UTIL_LINUX_SETPWNAM_H
#define UTIL_LINUX_SETPWNAM_H
-#include "pathnames.h"
-
-#ifndef DEBUG
-# define PASSWD_FILE _PATH_PASSWD
-# define GROUP_FILE _PATH_GROUP
-# define SHADOW_FILE _PATH_SHADOW_PASSWD
-# define SGROUP_FILE _PATH_GSHADOW
-#else
-# define PASSWD_FILE "/tmp/passwd"
-# define GROUP_FILE "/tmp/group"
-# define SHADOW_FILE "/tmp/shadow"
-# define SGROUP_FILE "/tmp/gshadow"
-#endif
-
extern int setpwnam (struct passwd *pwd, const char *prefix);
#endif /* UTIL_LINUX_SETPWNAM_H */
#include "fileutils.h"
#include "closestream.h"
#include "nls.h"
-#include "setpwnam.h"
+#include "pathnames.h"
#include "strutils.h"
#include "xalloc.h"
#include "rpmatch.h"
{
char tmp[FILENAMELEN + 4];
- snprintf(tmp, sizeof(tmp), "%s%s", orig_file, "-");
+ snprintf(tmp, sizeof(tmp), "%s%s", orig_file, _PATH_PASSWDBAK_SUFFIX);
unlink(tmp);
if (link(orig_file, tmp))
if (!strcmp(program_invocation_short_name, "vigr")) {
program = VIGR;
- xstrncpy(orig_file, GROUP_FILE, sizeof(orig_file));
+ xstrncpy(orig_file, _PATH_GROUP, sizeof(orig_file));
} else {
program = VIPW;
- xstrncpy(orig_file, PASSWD_FILE, sizeof(orig_file));
+ xstrncpy(orig_file, _PATH_PASSWD, sizeof(orig_file));
}
while ((c = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1) {
edit_file(0);
if (program == VIGR)
- xstrncpy(orig_file, SGROUP_FILE, sizeof(orig_file));
+ xstrncpy(orig_file, _PATH_GSHADOW, sizeof(orig_file));
else
- xstrncpy(orig_file, SHADOW_FILE, sizeof(orig_file));
+ xstrncpy(orig_file, _PATH_SHADOW, sizeof(orig_file));
if (access(orig_file, F_OK) == 0) {
char response[80];