[1604] in Moira

home help back first fref pref prev next nref lref last post

chsh fix

daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Tue Jul 11 22:02:11 2000

Message-Id: <200007120202.WAA23941@e40-spare-sun.mit.edu>
To: moiradev@MIT.EDU
cc: keithw@MIT.EDU
Date: Tue, 11 Jul 2000 22:02:06 -0400
From: Garry Zacheiss <zacheiss@MIT.EDU>

	This patch renames the global var uname to username.  On Linux,
we were conflicting with the uname() syscall; when an NIS function tries
to call uname(), it tries to execute code starting at the beginning of
our string.  All whackiness results.  I'm checking this in now.

	 Keith: next time, submit a bug report, instead of just a zephyr
at 5am.

Garry

Index: chsh.c
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/clients/chsh/chsh.c,v
retrieving revision 1.2
diff -c -r1.2 chsh.c
*** chsh.c	2000/05/01 08:18:01	1.2
--- chsh.c	2000/07/12 01:57:59
***************
*** 29,45 ****
  RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/clients/chsh/chsh.c,v 1.2 2000/05/01 08:18:01 zacheiss Exp $");
  
  void usage(void);
! int chsh(char *uname);
! int get_shell(int argc, char **argv, void *uname);
! int get_winshell(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);
  #endif
  
  char *whoami;
! char *uname;
  
  int main(int argc, char *argv[])
  {
--- 29,44 ----
  RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/clients/chsh/chsh.c,v 1.2 2000/05/01 08:18:01 zacheiss Exp $");
  
  void usage(void);
! int get_shell(int argc, char **argv, void *username);
! int get_winshell(int argc, char **argv, void *username);
! int get_fmodtime(int argc, char **argv, void *username);
  void check_shell(char *shell);
  #ifndef HAVE_GETUSERSHELL
  char *getusershell(void);
  #endif
  
  char *whoami;
! char *username;
  
  int main(int argc, char *argv[])
  {
***************
*** 78,93 ****
  		usage();
  	    }
  	}
!       else if (uname == NULL)
! 	uname = *arg;
        else
  	usage();
      }
  
!   if (!uname)
      {
!       uname = mrcl_krb_user();
!       if (!uname)
  	exit(1);
      }
  
--- 77,92 ----
  		usage();
  	    }
  	}
!       else if (username == NULL)
! 	username = *arg;
        else
  	usage();
      }
  
!   if (!username)
      {
!       username = mrcl_krb_user();
!       if (!username)
  	exit(1);
      }
  
***************
*** 102,108 ****
  
    /* First, do an access check */
  
!   q_argv[USH_NAME] = uname;
    q_argv[USH_SHELL] = "junk";
    q_argc = USH_END;
  
--- 101,107 ----
  
    /* First, do an access check */
  
!   q_argv[USH_NAME] = username;
    q_argv[USH_SHELL] = "junk";
    q_argc = USH_END;
  
***************
*** 112,126 ****
        exit(2);
      }
  
!   printf("Changing login shell for %s.\n", uname);
  
    /* Display current information */
    
!   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.");
        exit(2);
--- 111,125 ----
        exit(2);
      }
  
!   printf("Changing login shell for %s.\n", username);
  
    /* Display current information */
    
!   q_argv[NAME] = username;
    q_argc = NAME + 1;
    
    if ((status = mr_query("get_finger_by_login", q_argc, q_argv,
! 			 get_fmodtime, username)))
      {
        com_err(whoami, status, "while getting user information.");
        exit(2);
***************
*** 129,135 ****
    if (unixflg)
      {
        if ((status = mr_query("get_user_account_by_login", q_argc, q_argv,
! 			     get_shell, uname)))
  	{
  	  com_err(whoami, status, "while getting user information.");
  	  exit(2);
--- 128,134 ----
    if (unixflg)
      {
        if ((status = mr_query("get_user_account_by_login", q_argc, q_argv,
! 			     get_shell, username)))
  	{
  	  com_err(whoami, status, "while getting user information.");
  	  exit(2);
***************
*** 153,159 ****
        
        printf("Changing shell to %s...\n", shell);
        
!       q_argv[USH_NAME] = uname;
        q_argv[USH_SHELL] = shell;
        q_argc = USH_END;
        if ((status = mr_query("update_user_shell", q_argc, q_argv, NULL, NULL)))
--- 152,158 ----
        
        printf("Changing shell to %s...\n", shell);
        
!       q_argv[USH_NAME] = username;
        q_argv[USH_SHELL] = shell;
        q_argc = USH_END;
        if ((status = mr_query("update_user_shell", q_argc, q_argv, NULL, NULL)))
***************
*** 167,173 ****
    else if (windowsflg)
      {
        if ((status = mr_query("get_user_account_by_login", q_argc, q_argv,
! 			     get_winshell, uname)))
  	{
  	  com_err(whoami, status, "while getting user information.");
  	  exit(2);
--- 166,172 ----
    else if (windowsflg)
      {
        if ((status = mr_query("get_user_account_by_login", q_argc, q_argv,
! 			     get_winshell, username)))
  	{
  	  com_err(whoami, status, "while getting user information.");
  	  exit(2);
***************
*** 188,194 ****
        
        printf("Changing Windows shell to %s...\n", shell);
        
!       q_argv[USH_NAME] = uname;
        q_argv[USH_SHELL] = shell;
        q_argc = USH_END;
        if ((status = mr_query("update_user_windows_shell", q_argc, q_argv,
--- 187,193 ----
        
        printf("Changing Windows shell to %s...\n", shell);
        
!       q_argv[USH_NAME] = username;
        q_argv[USH_SHELL] = shell;
        q_argc = USH_END;
        if ((status = mr_query("update_user_windows_shell", q_argc, q_argv,
***************
*** 206,250 ****
    return 0;
  }
  
! int get_shell(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 < U_END || strcmp(argv[U_NAME], uname))
      {
        fprintf(stderr, "Some internal error has occurred.  Try again.\n");
        exit(3);
      }
  
!   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_winshell(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 < U_END || strcmp(argv[U_NAME], uname))
      {
        fprintf(stderr, "Some internal error has occurred.  Try again.\n");
        exit(3);
      }
  
!   printf("Current Windows shell for %s is %s.\n", (char *)uname, 
  	 argv[U_WINCONSOLESHELL]);
  
    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");
        exit(3);
--- 205,249 ----
    return 0;
  }
  
! int get_shell(int argc, char **argv, void *username)
  {
    /* We'll just take the first information we get since login names
       cannot be duplicated in the database. */
  
!   if (argc < U_END || strcmp(argv[U_NAME], username))
      {
        fprintf(stderr, "Some internal error has occurred.  Try again.\n");
        exit(3);
      }
  
!   printf("Current shell for %s is %s.\n", (char *)username, argv[U_SHELL]);
  
    return MR_ABORT;		/* Don't pay attention to other matches. */
  }
  
! int get_winshell(int argc, char **argv, void *username)
  {
    /* We'll just take the first information we get since login names
       cannot be duplicated in the database. */
  
!   if (argc < U_END || strcmp(argv[U_NAME], username))
      {
        fprintf(stderr, "Some internal error has occurred.  Try again.\n");
        exit(3);
      }
  
!   printf("Current Windows shell for %s is %s.\n", (char *)username, 
  	 argv[U_WINCONSOLESHELL]);
  
    return MR_ABORT;		/* Don't pay attention to other matches. */
  }
  
! int get_fmodtime(int argc, char **argv, void *username)
  {
    /* 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], username))
      {
        fprintf(stderr, "Some internal error has occurred.  Try again.\n");
        exit(3);


home help back first fref pref prev next nref lref last post