]> andersk Git - moira.git/commitdiff
Have chsh look up the fmodtime instead of the modtime in the user table.
authorkcr <kcr>
Fri, 30 Oct 1998 18:10:35 +0000 (18:10 +0000)
committerkcr <kcr>
Fri, 30 Oct 1998 18:10:35 +0000 (18:10 +0000)
Made uglier by the fact that you have to look up the fmodtime and the shell
with two different queries.  Should be revisited if danw ever adds gush.

clients/passwd/chsh.c

index 8a5e40b5f4576c3f1486b53b2a340e4539e94c82..e990050ae70fc8329df89cff71aae94964e6c73f 100644 (file)
@@ -31,6 +31,7 @@ int usage(void);
 int leave(int status);
 int chsh(char *uname);
 int get_shell(int argc, char **argv, void *uname);
+int get_fmodtime(int argc, char **argv, void *uname);
 void check_shell(char *shell);
 #ifndef HAVE_GETUSERSHELL
 char *getusershell(void);
@@ -146,6 +147,13 @@ int chsh(char *uname)
   q_argv[NAME] = uname;
   q_argc = NAME + 1;
 
+  if ((status = mr_query("get_finger_by_login", q_argc, q_argv,
+                        get_fmodtime, uname)))
+    {
+      com_err(whoami, status, " while getting user information.");
+      leave(2);
+    }
+
   if ((status = mr_query("get_user_account_by_login", q_argc, q_argv,
                         get_shell, uname)))
     {
@@ -197,13 +205,28 @@ int get_shell(int argc, char **argv, void *uname)
       leave(3);
     }
 
-  printf("Account information last changed on %s\n", argv[U_MODTIME]);
-  printf("by user %s with %s.\n", argv[U_MODBY], argv[U_MODWITH]);
   printf("Current shell for %s is %s.\n", (char *)uname, argv[U_SHELL]);
 
   return MR_ABORT;             /* Don't pay attention to other matches. */
 }
 
+int get_fmodtime(int argc, char **argv, void *uname)
+{
+  /* We'll just take the first information we get since login names
+     cannot be duplicated in the database. */
+
+  if (argc < F_END || strcmp(argv[F_NAME], uname))
+    {
+      fprintf(stderr, "Some internal error has occurred.  Try again.\n");
+      leave(3);
+    }
+
+  printf("Finger information last changed on %s\n", argv[F_MODTIME]);
+  printf("by user %s with %s.\n", argv[F_MODBY], argv[F_MODWITH]);
+
+  return MR_ABORT;             /* Don't pay attention to other matches. */
+}
+
 void check_shell(char *shell)
 {
   char *valid_shell;
This page took 0.036806 seconds and 5 git commands to generate.