Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/loginutils/su.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 983 by niro, Fri Apr 24 18:33:46 2009 UTC revision 984 by niro, Sun May 30 11:32:42 2010 UTC
# Line 40  int su_main(int argc UNUSED_PARAM, char Line 40  int su_main(int argc UNUSED_PARAM, char
40    
41   if (ENABLE_FEATURE_SU_SYSLOG) {   if (ENABLE_FEATURE_SU_SYSLOG) {
42   /* The utmp entry (via getlogin) is probably the best way to identify   /* The utmp entry (via getlogin) is probably the best way to identify
43   the user, especially if someone su's from a su-shell.   * the user, especially if someone su's from a su-shell.
44   But getlogin can fail -- usually due to lack of utmp entry.   * But getlogin can fail -- usually due to lack of utmp entry.
45   in this case resort to getpwuid.  */   * in this case resort to getpwuid.  */
46   old_user = xstrdup(USE_FEATURE_UTMP(getlogin() ? : ) (pw = getpwuid(cur_uid)) ? pw->pw_name : "");   const char *user;
47   tty = ttyname(2) ? : "none";  #if ENABLE_FEATURE_UTMP
48     char user_buf[64];
49     user = user_buf;
50     if (getlogin_r(user_buf, sizeof(user_buf)) != 0)
51    #endif
52     {
53     pw = getpwuid(cur_uid);
54     user = pw ? pw->pw_name : "";
55     }
56     old_user = xstrdup(user);
57     tty = xmalloc_ttyname(2);
58     if (!tty) {
59     tty = "none";
60     }
61   openlog(applet_name, 0, LOG_AUTH);   openlog(applet_name, 0, LOG_AUTH);
62   }   }
63    
64   pw = getpwnam(opt_username);   pw = xgetpwnam(opt_username);
  if (!pw)  
  bb_error_msg_and_die("unknown id: %s", opt_username);  
65    
66   /* Make sure pw->pw_shell is non-NULL.  It may be NULL when NEW_USER   /* Make sure pw->pw_shell is non-NULL.  It may be NULL when NEW_USER
67     is a username that is retrieved via NIS (YP), but that doesn't have     is a username that is retrieved via NIS (YP), but that doesn't have
# Line 93  int su_main(int argc UNUSED_PARAM, char Line 104  int su_main(int argc UNUSED_PARAM, char
104   change_identity(pw);   change_identity(pw);
105   /* setup_environment params: shell, clear_env, change_env, pw */   /* setup_environment params: shell, clear_env, change_env, pw */
106   setup_environment(opt_shell, flags & SU_OPT_l, !(flags & SU_OPT_mp), pw);   setup_environment(opt_shell, flags & SU_OPT_l, !(flags & SU_OPT_mp), pw);
107   USE_SELINUX(set_current_security_context(NULL);)   IF_SELINUX(set_current_security_context(NULL);)
108    
109   /* Never returns */   /* Never returns */
110   run_shell(opt_shell, flags & SU_OPT_l, opt_command, (const char**)argv);   run_shell(opt_shell, flags & SU_OPT_l, opt_command, (const char**)argv);

Legend:
Removed from v.983  
changed lines
  Added in v.984