]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
chsh: use pathnames.h for paths
authorSami Kerola <kerolasa@iki.fi>
Wed, 29 Feb 2012 01:05:22 +0000 (02:05 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sun, 18 Mar 2012 13:28:04 +0000 (14:28 +0100)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
include/pathnames.h
login-utils/chsh.c

index 3547e8e4a781084733dc29440c8efc70256b1f03..6c00d9f4ae83c766ee8bf3adc91115cbf0c703d6 100644 (file)
@@ -68,6 +68,7 @@
 #define _PATH_SHADOW_GROUP      "/etc/gshadow"
 #define _PATH_SHADOW_GTMP       "/etc/sgtmp"
 #define _PATH_SHADOW_GTMPTMP    "/etc/sgtmptmp"
+#define _PATH_SHELLS           "/etc/shells"
 
 /* used in term-utils/agetty.c */
 #define _PATH_ISSUE            "/etc/issue"
index 5481f7c387e9d601c6207f1c159d5f6fc98312e5..4f0615c082e3014e4c716cc2860ff615f80c0560 100644 (file)
@@ -118,9 +118,9 @@ int main(int argc, char **argv)
                                     pw->pw_name);
                        }
                }
-               if (setupDefaultContext("/etc/passwd") != 0)
+               if (setupDefaultContext(_PATH_PASSWD) != 0)
                        errx(EXIT_FAILURE,
-                            _("can't set default context for /etc/passwd"));
+                            _("can't set default context for %s"), _PATH_PASSWD);
        }
 #endif
 
@@ -137,8 +137,8 @@ int main(int argc, char **argv)
        }
        if (uid != 0 && !get_shell_list(oldshell)) {
                errno = EACCES;
-               err(EXIT_FAILURE, _("your shell is not in /etc/shells, "
-                                   "shell change denied"));
+               err(EXIT_FAILURE, _("your shell is not in %s, "
+                                   "shell change denied"), _PATH_SHELLS);
        }
 
        shell = info.shell;
@@ -316,18 +316,18 @@ static int check_shell(char *shell)
        if (!get_shell_list(shell)) {
                if (!getuid())
                        warnx(_
-                             ("Warning: \"%s\" is not listed in /etc/shells."),
-                             shell);
+                             ("Warning: \"%s\" is not listed in %s."),
+                             shell, _PATH_SHELLS);
                else
                        errx(EXIT_FAILURE,
-                            _("\"%s\" is not listed in /etc/shells.\n"
-                              "Use %s -l to see list."), shell,
+                            _("\"%s\" is not listed in %s.\n"
+                              "Use %s -l to see list."), shell, _PATH_SHELLS,
                             program_invocation_short_name);
        }
 #else
        if (!get_shell_list(shell)) {
-               warnx(_("\"%s\" is not listed in /etc/shells.\n"
-                       "Use %s -l to see list."), shell,
+               warnx(_("\"%s\" is not listed in %s.\n"
+                       "Use %s -l to see list."), shell, _PATH_SHELLS,
                      program_invocation_short_name);
        }
 #endif
@@ -347,7 +347,7 @@ static int get_shell_list(char *shell_name)
        char buf[PATH_MAX];
 
        found = false;
-       fp = fopen("/etc/shells", "r");
+       fp = fopen(_PATH_SHELLS, "r");
        if (!fp) {
                if (!shell_name)
                        warnx(_("No known shells."));