2006-12-06 17:25:32 -06:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 1987 Regents of the University of California.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
|
* are met:
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
|
* without specific prior written permission.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
* SUCH DAMAGE.
|
2006-12-06 17:25:33 -06:00
|
|
|
|
*
|
|
|
|
|
* Updated Thu Oct 12 09:56:55 1995 by faith@cs.unc.edu with security
|
|
|
|
|
* patches from Zefram <A.Main@dcs.warwick.ac.uk>
|
|
|
|
|
*
|
2011-11-13 13:03:48 -06:00
|
|
|
|
* Updated Thu Nov 9 21:58:53 1995 by Martin Schulze
|
2006-12-06 17:25:34 -06:00
|
|
|
|
* <joey@finlandia.infodrom.north.de>. Support for vigr.
|
|
|
|
|
*
|
|
|
|
|
* Martin Schulze's patches adapted to Util-Linux by Nicolai Langfeldt.
|
2006-12-06 17:25:39 -06:00
|
|
|
|
*
|
2006-12-06 17:25:46 -06:00
|
|
|
|
* 1999-02-22 Arkadiusz Mi<EFBFBD>kiewicz <misiek@pld.ORG.PL>
|
2006-12-06 17:25:39 -06:00
|
|
|
|
* - added Native Language Support
|
|
|
|
|
* Sun Mar 21 1999 - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
|
|
|
|
|
* - fixed strerr(errno) in gettext calls
|
2006-12-06 17:25:32 -06:00
|
|
|
|
*/
|
|
|
|
|
|
2012-02-28 16:05:59 -06:00
|
|
|
|
/*
|
|
|
|
|
* This command is deprecated. The utility is in maintenance mode,
|
|
|
|
|
* meaning we keep them in source tree for backward compatibility
|
|
|
|
|
* only. Do not waste time making this command better, unless the
|
|
|
|
|
* fix is about security or other very critical issue.
|
|
|
|
|
*
|
|
|
|
|
* See Documentation/deprecated.txt for more information.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-11-13 13:03:48 -06:00
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <paths.h>
|
2006-12-06 17:25:32 -06:00
|
|
|
|
#include <pwd.h>
|
2011-11-13 13:03:48 -06:00
|
|
|
|
#include <signal.h>
|
2006-12-06 17:25:32 -06:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
2011-11-13 13:03:48 -06:00
|
|
|
|
#include <sys/file.h>
|
2006-12-06 17:25:32 -06:00
|
|
|
|
#include <sys/param.h>
|
2011-11-13 13:03:48 -06:00
|
|
|
|
#include <sys/resource.h>
|
|
|
|
|
#include <sys/stat.h>
|
2006-12-06 17:25:32 -06:00
|
|
|
|
#include <sys/time.h>
|
2011-11-13 13:03:48 -06:00
|
|
|
|
#include <sys/types.h>
|
2006-12-06 17:25:32 -06:00
|
|
|
|
#include <sys/wait.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
2011-11-13 13:03:48 -06:00
|
|
|
|
#include "c.h"
|
|
|
|
|
#include "nls.h"
|
2006-12-06 17:25:34 -06:00
|
|
|
|
#include "setpwnam.h"
|
2010-11-16 07:47:35 -06:00
|
|
|
|
#include "strutils.h"
|
2012-02-06 04:22:54 -06:00
|
|
|
|
#include "xalloc.h"
|
2006-12-06 17:25:32 -06:00
|
|
|
|
|
2006-12-06 17:26:54 -06:00
|
|
|
|
#ifdef HAVE_LIBSELINUX
|
2011-11-13 13:03:48 -06:00
|
|
|
|
# include <selinux/selinux.h>
|
2006-12-06 17:26:14 -06:00
|
|
|
|
#endif
|
|
|
|
|
|
2006-12-06 17:25:34 -06:00
|
|
|
|
#define FILENAMELEN 67
|
2006-12-06 17:25:32 -06:00
|
|
|
|
|
2011-11-13 13:03:48 -06:00
|
|
|
|
enum {
|
|
|
|
|
VIPW,
|
|
|
|
|
VIGR
|
|
|
|
|
};
|
2006-12-06 17:25:34 -06:00
|
|
|
|
int program;
|
2011-11-13 13:03:48 -06:00
|
|
|
|
char orig_file[FILENAMELEN]; /* original file /etc/passwd or /etc/group */
|
|
|
|
|
char tmp_file[FILENAMELEN]; /* tmp file */
|
|
|
|
|
char tmptmp_file[FILENAMELEN]; /* very tmp file */
|
2006-12-06 17:25:32 -06:00
|
|
|
|
|
2006-12-06 17:25:34 -06:00
|
|
|
|
void pw_error __P((char *, int, int));
|
2006-12-06 17:25:32 -06:00
|
|
|
|
|
2011-11-13 13:03:48 -06:00
|
|
|
|
static void copyfile(int from, int to)
|
|
|
|
|
{
|
2006-12-06 17:25:44 -06:00
|
|
|
|
int nr, nw, off;
|
2011-11-13 13:03:48 -06:00
|
|
|
|
char buf[8 * 1024];
|
2010-12-01 10:18:38 -06:00
|
|
|
|
|
2006-12-06 17:25:32 -06:00
|
|
|
|
while ((nr = read(from, buf, sizeof(buf))) > 0)
|
|
|
|
|
for (off = 0; off < nr; nr -= nw, off += nw)
|
|
|
|
|
if ((nw = write(to, buf + off, nr)) < 0)
|
2011-11-13 13:03:48 -06:00
|
|
|
|
pw_error(tmp_file, 1, 1);
|
2006-12-06 17:25:34 -06:00
|
|
|
|
|
2006-12-06 17:25:32 -06:00
|
|
|
|
if (nr < 0)
|
2011-11-13 13:03:48 -06:00
|
|
|
|
pw_error(orig_file, 1, 1);
|
2006-12-06 17:25:32 -06:00
|
|
|
|
}
|
|
|
|
|
|
2011-11-13 13:03:48 -06:00
|
|
|
|
static void pw_init(void)
|
|
|
|
|
{
|
2006-12-06 17:25:32 -06:00
|
|
|
|
struct rlimit rlim;
|
|
|
|
|
|
|
|
|
|
/* Unlimited resource limits. */
|
|
|
|
|
rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY;
|
|
|
|
|
(void)setrlimit(RLIMIT_CPU, &rlim);
|
|
|
|
|
(void)setrlimit(RLIMIT_FSIZE, &rlim);
|
|
|
|
|
(void)setrlimit(RLIMIT_STACK, &rlim);
|
|
|
|
|
(void)setrlimit(RLIMIT_DATA, &rlim);
|
|
|
|
|
(void)setrlimit(RLIMIT_RSS, &rlim);
|
|
|
|
|
|
|
|
|
|
/* Don't drop core (not really necessary, but GP's). */
|
|
|
|
|
rlim.rlim_cur = rlim.rlim_max = 0;
|
|
|
|
|
(void)setrlimit(RLIMIT_CORE, &rlim);
|
|
|
|
|
|
|
|
|
|
/* Turn off signals. */
|
|
|
|
|
(void)signal(SIGALRM, SIG_IGN);
|
|
|
|
|
(void)signal(SIGHUP, SIG_IGN);
|
|
|
|
|
(void)signal(SIGINT, SIG_IGN);
|
|
|
|
|
(void)signal(SIGPIPE, SIG_IGN);
|
|
|
|
|
(void)signal(SIGQUIT, SIG_IGN);
|
|
|
|
|
(void)signal(SIGTERM, SIG_IGN);
|
|
|
|
|
(void)signal(SIGTSTP, SIG_IGN);
|
|
|
|
|
(void)signal(SIGTTOU, SIG_IGN);
|
|
|
|
|
|
|
|
|
|
/* Create with exact permissions. */
|
|
|
|
|
(void)umask(0);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-13 13:03:48 -06:00
|
|
|
|
static int pw_lock(void)
|
|
|
|
|
{
|
2006-12-06 17:25:32 -06:00
|
|
|
|
int lockfd, fd, ret;
|
|
|
|
|
|
2010-12-01 10:18:38 -06:00
|
|
|
|
/*
|
2011-11-13 13:03:48 -06:00
|
|
|
|
* If the password file doesn't exist, the system is hosed. Might as
|
|
|
|
|
* well try to build one. Set the close-on-exec bit so that users
|
|
|
|
|
* can't get at the encrypted passwords while editing. Open should
|
|
|
|
|
* allow flock'ing the file; see 4.4BSD. XXX
|
2006-12-06 17:25:32 -06:00
|
|
|
|
*/
|
2011-11-13 13:03:48 -06:00
|
|
|
|
#if 0
|
|
|
|
|
/* flock()ing is superfluous here, with the ptmp/ptmptmp system. */
|
|
|
|
|
if (flock(lockfd, LOCK_EX | LOCK_NB)) {
|
2006-12-06 17:25:49 -06:00
|
|
|
|
if (program == VIPW)
|
2011-11-13 08:12:44 -06:00
|
|
|
|
err(EXIT_FAILURE, _("cannot lock password file"));
|
2006-12-06 17:25:49 -06:00
|
|
|
|
else
|
2011-11-13 08:12:44 -06:00
|
|
|
|
err(EXIT_FAILURE, _("cannot lock group file"));
|
2006-12-06 17:25:32 -06:00
|
|
|
|
}
|
2006-12-06 17:25:33 -06:00
|
|
|
|
#endif
|
2006-12-06 17:25:32 -06:00
|
|
|
|
|
2011-11-13 13:03:48 -06:00
|
|
|
|
if ((fd = open(tmptmp_file, O_WRONLY | O_CREAT, 0600)) == -1)
|
|
|
|
|
err(EXIT_FAILURE, _("%s: open failed"), tmptmp_file);
|
2010-12-01 10:18:38 -06:00
|
|
|
|
|
2006-12-06 17:25:34 -06:00
|
|
|
|
ret = link(tmptmp_file, tmp_file);
|
|
|
|
|
(void)unlink(tmptmp_file);
|
2006-12-06 17:25:32 -06:00
|
|
|
|
if (ret == -1) {
|
2011-11-13 13:03:48 -06:00
|
|
|
|
if (errno == EEXIST)
|
|
|
|
|
errx(EXIT_FAILURE,
|
|
|
|
|
_("the %s file is busy (%s present)"),
|
|
|
|
|
program == VIPW ? "password" : "group", tmp_file);
|
|
|
|
|
else
|
|
|
|
|
err(EXIT_FAILURE, _("can't link %s"), tmp_file);
|
2006-12-06 17:25:32 -06:00
|
|
|
|
}
|
2006-12-06 17:25:46 -06:00
|
|
|
|
|
|
|
|
|
lockfd = open(orig_file, O_RDONLY, 0);
|
|
|
|
|
|
|
|
|
|
if (lockfd < 0) {
|
2011-11-13 08:12:44 -06:00
|
|
|
|
warn("%s", orig_file);
|
2006-12-06 17:25:46 -06:00
|
|
|
|
unlink(tmp_file);
|
2010-12-01 10:18:38 -06:00
|
|
|
|
exit(EXIT_FAILURE);
|
2006-12-06 17:25:46 -06:00
|
|
|
|
}
|
|
|
|
|
|
2006-12-06 17:25:32 -06:00
|
|
|
|
copyfile(lockfd, fd);
|
|
|
|
|
(void)close(lockfd);
|
|
|
|
|
(void)close(fd);
|
2010-12-01 10:18:38 -06:00
|
|
|
|
return 1;
|
2006-12-06 17:25:32 -06:00
|
|
|
|
}
|
|
|
|
|
|
2011-11-13 13:03:48 -06:00
|
|
|
|
static void pw_unlock(void)
|
|
|
|
|
{
|
|
|
|
|
char tmp[FILENAMELEN + 4];
|
|
|
|
|
|
2006-12-06 17:25:49 -06:00
|
|
|
|
sprintf(tmp, "%s%s", orig_file, ".OLD");
|
|
|
|
|
unlink(tmp);
|
2010-12-10 10:07:44 -06:00
|
|
|
|
|
|
|
|
|
if (link(orig_file, tmp))
|
|
|
|
|
warn(_("%s: create a link to %s failed"), orig_file, tmp);
|
2006-12-06 17:26:14 -06:00
|
|
|
|
|
2006-12-06 17:26:54 -06:00
|
|
|
|
#ifdef HAVE_LIBSELINUX
|
2008-07-01 07:24:58 -05:00
|
|
|
|
if (is_selinux_enabled() > 0) {
|
2011-11-13 13:03:48 -06:00
|
|
|
|
security_context_t passwd_context = NULL;
|
|
|
|
|
int ret = 0;
|
|
|
|
|
if (getfilecon(orig_file, &passwd_context) < 0) {
|
|
|
|
|
warnx(_("Can't get context for %s"), orig_file);
|
|
|
|
|
pw_error(orig_file, 1, 1);
|
|
|
|
|
}
|
|
|
|
|
ret = setfilecon(tmp_file, passwd_context);
|
|
|
|
|
freecon(passwd_context);
|
|
|
|
|
if (ret != 0) {
|
|
|
|
|
warnx(_("Can't set context for %s"), tmp_file);
|
|
|
|
|
pw_error(tmp_file, 1, 1);
|
|
|
|
|
}
|
2006-12-06 17:26:14 -06:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-12-06 17:25:49 -06:00
|
|
|
|
if (rename(tmp_file, orig_file) == -1) {
|
|
|
|
|
int errsv = errno;
|
2011-11-13 08:12:44 -06:00
|
|
|
|
errx(EXIT_FAILURE,
|
|
|
|
|
("can't unlock %s: %s (your changes are still in %s)"),
|
|
|
|
|
orig_file, strerror(errsv), tmp_file);
|
2006-12-06 17:25:49 -06:00
|
|
|
|
}
|
|
|
|
|
unlink(tmp_file);
|
2006-12-06 17:25:32 -06:00
|
|
|
|
}
|
|
|
|
|
|
2011-11-13 13:03:48 -06:00
|
|
|
|
static void pw_edit(int notsetuid)
|
|
|
|
|
{
|
2006-12-06 17:25:32 -06:00
|
|
|
|
int pstat;
|
|
|
|
|
pid_t pid;
|
2012-02-01 05:41:25 -06:00
|
|
|
|
char *p, *editor, *tk;
|
2006-12-06 17:25:32 -06:00
|
|
|
|
|
2012-02-01 05:41:25 -06:00
|
|
|
|
editor = getenv("EDITOR");
|
2012-02-06 04:22:54 -06:00
|
|
|
|
editor = xstrdup(editor ? editor : _PATH_VI);
|
2012-02-01 05:41:25 -06:00
|
|
|
|
|
|
|
|
|
tk = strtok(editor, " \t");
|
|
|
|
|
if (tk && (p = strrchr(tk, '/')) != NULL)
|
2006-12-06 17:25:32 -06:00
|
|
|
|
++p;
|
2011-11-13 13:03:48 -06:00
|
|
|
|
else
|
2006-12-06 17:25:32 -06:00
|
|
|
|
p = editor;
|
|
|
|
|
|
2006-12-06 17:25:35 -06:00
|
|
|
|
pid = fork();
|
2010-12-01 10:18:38 -06:00
|
|
|
|
if (pid < 0)
|
|
|
|
|
err(EXIT_FAILURE, _("fork failed"));
|
|
|
|
|
|
2006-12-06 17:25:35 -06:00
|
|
|
|
if (!pid) {
|
2006-12-06 17:25:32 -06:00
|
|
|
|
if (notsetuid) {
|
|
|
|
|
(void)setgid(getgid());
|
|
|
|
|
(void)setuid(getuid());
|
|
|
|
|
}
|
2006-12-06 17:25:34 -06:00
|
|
|
|
execlp(editor, p, tmp_file, NULL);
|
2010-12-01 10:18:38 -06:00
|
|
|
|
/* Shouldn't get here */
|
|
|
|
|
_exit(EXIT_FAILURE);
|
2006-12-06 17:25:32 -06:00
|
|
|
|
}
|
|
|
|
|
for (;;) {
|
2011-11-13 13:03:48 -06:00
|
|
|
|
pid = waitpid(pid, &pstat, WUNTRACED);
|
|
|
|
|
if (WIFSTOPPED(pstat)) {
|
|
|
|
|
/* the editor suspended, so suspend us as well */
|
|
|
|
|
kill(getpid(), SIGSTOP);
|
|
|
|
|
kill(pid, SIGCONT);
|
|
|
|
|
} else {
|
|
|
|
|
break;
|
|
|
|
|
}
|
2006-12-06 17:25:32 -06:00
|
|
|
|
}
|
|
|
|
|
if (pid == -1 || !WIFEXITED(pstat) || WEXITSTATUS(pstat) != 0)
|
|
|
|
|
pw_error(editor, 1, 1);
|
2012-02-06 04:22:54 -06:00
|
|
|
|
|
|
|
|
|
free(editor);
|
2006-12-06 17:25:32 -06:00
|
|
|
|
}
|
|
|
|
|
|
2011-11-13 13:03:48 -06:00
|
|
|
|
void pw_error(char *name, int err, int eval)
|
|
|
|
|
{
|
2006-12-06 17:25:32 -06:00
|
|
|
|
if (err) {
|
|
|
|
|
if (name)
|
2011-11-13 08:12:44 -06:00
|
|
|
|
warn("%s: ", name);
|
|
|
|
|
else
|
|
|
|
|
warn(NULL);
|
2006-12-06 17:25:32 -06:00
|
|
|
|
}
|
2011-11-13 08:12:44 -06:00
|
|
|
|
warnx(_("%s unchanged"), orig_file);
|
2006-12-06 17:25:49 -06:00
|
|
|
|
unlink(tmp_file);
|
2006-12-06 17:25:32 -06:00
|
|
|
|
exit(eval);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-13 13:03:48 -06:00
|
|
|
|
static void edit_file(int is_shadow)
|
2006-12-06 17:25:46 -06:00
|
|
|
|
{
|
|
|
|
|
struct stat begin, end;
|
|
|
|
|
|
|
|
|
|
pw_init();
|
|
|
|
|
pw_lock();
|
|
|
|
|
|
|
|
|
|
if (stat(tmp_file, &begin))
|
|
|
|
|
pw_error(tmp_file, 1, 1);
|
2006-12-06 17:26:14 -06:00
|
|
|
|
|
2006-12-06 17:25:46 -06:00
|
|
|
|
pw_edit(0);
|
2006-12-06 17:26:14 -06:00
|
|
|
|
|
2006-12-06 17:25:46 -06:00
|
|
|
|
if (stat(tmp_file, &end))
|
|
|
|
|
pw_error(tmp_file, 1, 1);
|
|
|
|
|
if (begin.st_mtime == end.st_mtime) {
|
2011-11-13 08:12:44 -06:00
|
|
|
|
warnx(_("no changes made"));
|
2006-12-06 17:25:46 -06:00
|
|
|
|
pw_error((char *)NULL, 0, 0);
|
|
|
|
|
}
|
2007-02-15 04:46:23 -06:00
|
|
|
|
/* see pw_lock() where we create the file with mode 600 */
|
2006-12-06 17:25:49 -06:00
|
|
|
|
if (!is_shadow)
|
|
|
|
|
chmod(tmp_file, 0644);
|
|
|
|
|
else
|
|
|
|
|
chmod(tmp_file, 0400);
|
2006-12-06 17:25:46 -06:00
|
|
|
|
pw_unlock();
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-13 13:03:48 -06:00
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
2006-12-06 17:25:49 -06:00
|
|
|
|
setlocale(LC_ALL, "");
|
|
|
|
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
|
|
|
|
textdomain(PACKAGE);
|
|
|
|
|
|
2009-08-17 00:27:39 -05:00
|
|
|
|
memset(tmp_file, '\0', FILENAMELEN);
|
2011-11-13 08:12:44 -06:00
|
|
|
|
if (!strcmp(program_invocation_short_name, "vigr")) {
|
2006-12-06 17:25:49 -06:00
|
|
|
|
program = VIGR;
|
|
|
|
|
xstrncpy(orig_file, GROUP_FILE, sizeof(orig_file));
|
|
|
|
|
xstrncpy(tmp_file, GTMP_FILE, sizeof(tmp_file));
|
|
|
|
|
xstrncpy(tmptmp_file, GTMPTMP_FILE, sizeof(tmptmp_file));
|
|
|
|
|
} else {
|
|
|
|
|
program = VIPW;
|
|
|
|
|
xstrncpy(orig_file, PASSWD_FILE, sizeof(orig_file));
|
|
|
|
|
xstrncpy(tmp_file, PTMP_FILE, sizeof(tmp_file));
|
|
|
|
|
xstrncpy(tmptmp_file, PTMPTMP_FILE, sizeof(tmptmp_file));
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-01 10:18:38 -06:00
|
|
|
|
if ((argc > 1) &&
|
2006-12-06 17:25:49 -06:00
|
|
|
|
(!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version"))) {
|
2011-11-13 08:14:33 -06:00
|
|
|
|
printf(UTIL_LINUX_VERSION);
|
2010-12-01 10:18:38 -06:00
|
|
|
|
exit(EXIT_SUCCESS);
|
2006-12-06 17:25:49 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
edit_file(0);
|
|
|
|
|
|
|
|
|
|
if (program == VIGR) {
|
2011-11-13 13:03:48 -06:00
|
|
|
|
strncpy(orig_file, SGROUP_FILE, FILENAMELEN - 1);
|
|
|
|
|
strncpy(tmp_file, SGTMP_FILE, FILENAMELEN - 1);
|
|
|
|
|
strncpy(tmptmp_file, SGTMPTMP_FILE, FILENAMELEN - 1);
|
2006-12-06 17:25:49 -06:00
|
|
|
|
} else {
|
2011-11-13 13:03:48 -06:00
|
|
|
|
strncpy(orig_file, SHADOW_FILE, FILENAMELEN - 1);
|
|
|
|
|
strncpy(tmp_file, SPTMP_FILE, FILENAMELEN - 1);
|
|
|
|
|
strncpy(tmptmp_file, SPTMPTMP_FILE, FILENAMELEN - 1);
|
2006-12-06 17:25:49 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (access(orig_file, F_OK) == 0) {
|
|
|
|
|
char response[80];
|
|
|
|
|
|
|
|
|
|
printf((program == VIGR)
|
|
|
|
|
? _("You are using shadow groups on this system.\n")
|
|
|
|
|
: _("You are using shadow passwords on this system.\n"));
|
|
|
|
|
printf(_("Would you like to edit %s now [y/n]? "), orig_file);
|
|
|
|
|
|
|
|
|
|
/* EOF means no */
|
|
|
|
|
if (fgets(response, sizeof(response), stdin)) {
|
|
|
|
|
if (response[0] == 'y' || response[0] == 'Y')
|
|
|
|
|
edit_file(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-01 10:18:38 -06:00
|
|
|
|
exit(EXIT_SUCCESS);
|
2006-12-06 17:25:32 -06:00
|
|
|
|
}
|