亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? su.c

?? 《Linux應(yīng)用開發(fā)技術(shù)詳解》附書光盤中的例程。
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* su for GNU.  Run a shell with substitute user and group IDs.
   Copyright (C) 1992-2002 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software Foundation,
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

/* Run a shell with the real and effective UID and GID and groups
   of USER, default `root'.

   The shell run is taken from USER's password entry, /bin/sh if
   none is specified there.  If the account has a password, su
   prompts for a password unless run by a user with real UID 0.

   Does not change the current directory.
   Sets `HOME' and `SHELL' from the password entry for USER, and if
   USER is not root, sets `USER' and `LOGNAME' to USER.
   The subshell is not a login shell.

   If one or more ARGs are given, they are passed as additional
   arguments to the subshell.

   Does not handle /bin/sh or other shells specially
   (setting argv[0] to "-su", passing -c only to certain shells, etc.).
   I don't see the point in doing that, and it's ugly.

   This program intentionally does not support a "wheel group" that
   restricts who can su to UID 0 accounts.  RMS considers that to
   be fascist.

#ifdef USE_PAM

   Actually, with PAM, su has nothing to do with whether or not a
   wheel group is enforced by su.  RMS tries to restrict your access
   to a su which implements the wheel group, but PAM considers that
   to be fascist, and gives the user/sysadmin the opportunity to
   enforce a wheel group by proper editing of /etc/pam.conf

#endif

   Options:
   -, -l, --login	Make the subshell a login shell.
			Unset all environment variables except
			TERM, HOME and SHELL (set as above), and USER
			and LOGNAME (set unconditionally as above), and
			set PATH to a default value.
			Change to USER's home directory.
			Prepend "-" to the shell's name.
   -c, --commmand=COMMAND
			Pass COMMAND to the subshell with a -c option
			instead of starting an interactive shell.
   -f, --fast		Pass the -f option to the subshell.
   -m, -p, --preserve-environment
			Do not change HOME, USER, LOGNAME, SHELL.
			Run $SHELL instead of USER's shell from /etc/passwd
			unless not the superuser and USER's shell is
			restricted.
			Overridden by --login and --shell.
   -s, --shell=shell	Run SHELL instead of USER's shell from /etc/passwd
			unless not the superuser and USER's shell is
			restricted.

   Compile-time options:
   -DSYSLOG_SUCCESS	Log successful su's (by default, to root) with syslog.
   -DSYSLOG_FAILURE	Log failed su's (by default, to root) with syslog.

   -DSYSLOG_NON_ROOT	Log all su's, not just those to root (UID 0).
   Never logs attempted su's to nonexistent accounts.

   Written by David MacKenzie <djm@gnu.ai.mit.edu>.  */

#include <config.h>
#include <stdio.h>
#include <getopt.h>
#include <sys/types.h>
#include <pwd.h>
#include <grp.h>

/* Hide any system prototype for getusershell.
   This is necessary because some Cray systems have a conflicting
   prototype (returning `int') in <unistd.h>.  */
#define getusershell _getusershell_sys_proto_

#ifdef USE_PAM
# include <security/pam_appl.h>
# include <security/pam_misc.h>
# include <signal.h>
# include <sys/wait.h>
# include <sys/fsuid.h>
#endif /* USE_PAM */

#include "system.h"
#include "closeout.h"
#include "dirname.h"

#undef getusershell

#if HAVE_SYSLOG_H && HAVE_SYSLOG
# include <syslog.h>
#else
# undef SYSLOG_SUCCESS
# undef SYSLOG_FAILURE
# undef SYSLOG_NON_ROOT
#endif

#if HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif

#ifndef HAVE_ENDGRENT
# define endgrent() ((void) 0)
#endif

#ifndef HAVE_ENDPWENT
# define endpwent() ((void) 0)
#endif

#if HAVE_SHADOW_H
# include <shadow.h>
#endif

#include "error.h"

/* The official name of this program (e.g., no `g' prefix).  */
#define PROGRAM_NAME "su"

#define AUTHORS "David MacKenzie"

#if HAVE_PATHS_H
# include <paths.h>
#endif

/* The default PATH for simulated logins to non-superuser accounts.  */
#ifdef _PATH_DEFPATH
# define DEFAULT_LOGIN_PATH _PATH_DEFPATH
#else
# define DEFAULT_LOGIN_PATH ":/usr/ucb:/bin:/usr/bin"
#endif

/* The default PATH for simulated logins to superuser accounts.  */
#ifdef _PATH_DEFPATH_ROOT
# define DEFAULT_ROOT_LOGIN_PATH _PATH_DEFPATH_ROOT
#else
# define DEFAULT_ROOT_LOGIN_PATH "/usr/ucb:/bin:/usr/bin:/etc"
#endif

/* The default paths which get set are both bogus and oddly influenced
   by <paths.h> and -D on the commands line. Just to be clear, we'll set
   these explicitly. -ewt */
#undef DEFAULT_LOGIN_PATH
#undef DEFAULT_ROOT_LOGIN_PATH
#define DEFAULT_LOGIN_PATH "/bin:/usr/bin:/usr/local/bin:/usr/bin/X11"
#define DEFAULT_ROOT_LOGIN_PATH \
    "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin/X11"

/* The shell to run if none is given in the user's passwd entry.  */
#define DEFAULT_SHELL "/bin/sh"

/* The user to become if none is specified.  */
#define DEFAULT_USER "root"

#ifndef USE_PAM
char *crypt ();
#endif
char *getpass ();
char *getusershell ();
void endusershell ();
void setusershell ();

extern char **environ;

static void run_shell (const char *, const char *, char **, const struct passwd *)
#ifdef USE_PAM
     ;
#else
     ATTRIBUTE_NORETURN;
#endif

/* The name this program was run with.  */
char *program_name;

/* If nonzero, pass the `-f' option to the subshell.  */
static int fast_startup;

/* If nonzero, simulate a login instead of just starting a shell.  */
static int simulate_login;

/* If nonzero, change some environment vars to indicate the user su'd to.  */
static int change_environment;

static struct option const longopts[] =
{
  {"command", required_argument, 0, 'c'},
  {"fast", no_argument, NULL, 'f'},
  {"login", no_argument, NULL, 'l'},
  {"preserve-environment", no_argument, &change_environment, 0},
  {"shell", required_argument, 0, 's'},
  {GETOPT_HELP_OPTION_DECL},
  {GETOPT_VERSION_OPTION_DECL},
  {0, 0, 0, 0}
};

/* Add VAL to the environment, checking for out of memory errors.  */

static void
xputenv (char *val)
{
  if (putenv (val))
    xalloc_die ();
}

/* Return a newly-allocated string whose contents concatenate
   those of S1, S2, S3.  */

static char *
concat (const char *s1, const char *s2, const char *s3)
{
  int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
  char *result = (char *) xmalloc (len1 + len2 + len3 + 1);

  strcpy (result, s1);
  strcpy (result + len1, s2);
  strcpy (result + len1 + len2, s3);
  result[len1 + len2 + len3] = 0;

  return result;
}

/* Return the number of elements in ARR, a null-terminated array.  */

static int
elements (char **arr)
{
  int n = 0;

  for (n = 0; *arr; ++arr)
    ++n;
  return n;
}

#if defined (SYSLOG_SUCCESS) || defined (SYSLOG_FAILURE)
/* Log the fact that someone has run su to the user given by PW;
   if SUCCESSFUL is nonzero, they gave the correct password, etc.  */

static void
log_su (const struct passwd *pw, int successful)
{
  const char *new_user, *old_user, *tty;

# ifndef SYSLOG_NON_ROOT
  if (pw->pw_uid)
    return;
# endif
  new_user = pw->pw_name;
  /* The utmp entry (via getlogin) is probably the best way to identify
     the user, especially if someone su's from a su-shell.  */
  old_user = getlogin ();
  if (old_user == NULL)
    {
      /* getlogin can fail -- usually due to lack of utmp entry.
	 Resort to getpwuid.  */
      struct passwd *pwd = getpwuid (getuid ());
      old_user = (pwd ? pwd->pw_name : "");
    }
  tty = ttyname (2);
  if (tty == NULL)
    tty = "none";
  /* 4.2BSD openlog doesn't have the third parameter.  */
  openlog (base_name (program_name), 0
# ifdef LOG_AUTH
	   , LOG_AUTH
# endif
	   );
  syslog (LOG_NOTICE,
# ifdef SYSLOG_NON_ROOT
	  "%s(to %s) %s on %s",
# else
	  "%s%s on %s",
# endif
	  successful ? "" : "FAILED SU ",
# ifdef SYSLOG_NON_ROOT
	  new_user,
# endif
	  old_user, tty);
  closelog ();
}
#endif

#ifdef USE_PAM
static pam_handle_t *pamh = NULL;
static int retval;
static struct pam_conv conv = {
  misc_conv,
  NULL
};

#define PAM_BAIL_P if (retval) { \
  pam_end(pamh, PAM_SUCCESS); \
  return 0; \
}
#endif

/* Ask the user for a password.
   If PAM is in use, let PAM ask for the password if necessary.
   Return 1 if the user gives the correct password for entry PW,
   0 if not.  Return 1 without asking for a password if run by UID 0
   or if PW has an empty password.  */

static int
correct_password (const struct passwd *pw)
{
#ifdef USE_PAM
  struct passwd *caller;
  retval = pam_start(PROGRAM_NAME, pw->pw_name, &conv, &pamh);
  PAM_BAIL_P;

  if (getuid() != 0 && !isatty(0)) {
	fprintf(stderr, "standard in must be a tty\n");
	exit(1);
  }

  caller = getpwuid(getuid());
  if(caller != NULL && caller->pw_name != NULL) {
	  retval = pam_set_item(pamh, PAM_RUSER, caller->pw_name);
	  PAM_BAIL_P;
  }

  retval = pam_authenticate(pamh, 0);
  PAM_BAIL_P;
  retval = pam_acct_mgmt(pamh, 0);
  if (retval == PAM_NEW_AUTHTOK_REQD) {
    /* password has expired.  Offer option to change it. */
    retval = pam_chauthtok(pamh, PAM_CHANGE_EXPIRED_AUTHTOK);
    PAM_BAIL_P;
  }
  PAM_BAIL_P;
  /* must be authenticated if this point was reached */
  return 1;
#else /* !USE_PAM */
  char *unencrypted, *encrypted, *correct;
#if HAVE_GETSPNAM && HAVE_STRUCT_SPWD_SP_PWDP
  /* Shadow passwd stuff for SVR3 and maybe other systems.  */
  struct spwd *sp = getspnam (pw->pw_name);

  endspent ();
  if (sp)
    correct = sp->sp_pwdp;
  else
#endif
    correct = pw->pw_passwd;

  if (getuid () == 0 || correct == 0 || correct[0] == '\0')
    return 1;

  unencrypted = getpass (_("Password:"));
  if (unencrypted == NULL)
    {
      error (0, 0, _("getpass: cannot open /dev/tty"));
      return 0;
    }
  encrypted = crypt (unencrypted, correct);
  memset (unencrypted, 0, strlen (unencrypted));
  return strcmp (encrypted, correct) == 0;
#endif /* !USE_PAM */
}

/* Update `environ' for the new shell based on PW, with SHELL being
   the value for the SHELL environment variable.  */

static void
modify_environment (const struct passwd *pw, const char *shell)
{
  char *term;
  char *display;
  char *xauthority;

  if (simulate_login)
    {
      /* Leave TERM, DISPLAY, XAUTHORITY unchanged.  Set HOME, SHELL, USER, LOGNAME, PATH.
         Unset all other environment variables.  */
      term = getenv ("TERM");
      display = getenv ("DISPLAY");
      xauthority = getenv ("XAUTHORITY");

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产精品ⅴa在线观看| 在线不卡一区二区| 国产精品毛片无遮挡高清| 高清不卡一二三区| ...xxx性欧美| 欧美性大战久久久| 九九国产精品视频| 欧美国产1区2区| 欧美综合亚洲图片综合区| 亚洲成人一区二区在线观看| 欧美一区三区四区| 国产精品正在播放| 一区二区三区四区不卡视频| 欧美狂野另类xxxxoooo| 韩国精品免费视频| 亚洲视频图片小说| 91精品国产手机| av一本久道久久综合久久鬼色| 国产精品久久99| 在线不卡免费av| 99久久久国产精品免费蜜臀| 丝袜亚洲另类欧美| 国产欧美一二三区| 欧美老肥妇做.爰bbww| 色又黄又爽网站www久久| 调教+趴+乳夹+国产+精品| 国产人伦精品一区二区| 欧美日韩综合一区| eeuss影院一区二区三区| 日韩国产在线观看一区| 中文字幕一区二区在线播放| 成人午夜在线播放| |精品福利一区二区三区| 日韩一二三四区| 99久久久久久99| 韩国三级电影一区二区| 一区二区国产视频| 久久久久久麻豆| 在线综合视频播放| 97se亚洲国产综合在线| 国产永久精品大片wwwapp | 久久综合久久鬼色| 色婷婷av一区二区三区gif | 欧美日韩高清在线| 波多野结衣一区二区三区| 麻豆freexxxx性91精品| 亚洲自拍偷拍综合| 中文字幕日本不卡| 中文字幕精品在线不卡| 日韩欧美在线不卡| 欧美日韩一区中文字幕| 91视频在线看| 不卡一区二区三区四区| 狠狠色丁香婷综合久久| 日韩黄色免费网站| 亚洲一二三四在线| 亚洲精品国产无天堂网2021| 国产精品欧美经典| 国产日韩精品久久久| 精品99一区二区三区| 4hu四虎永久在线影院成人| 91国产丝袜在线播放| 99久久久久免费精品国产| 粉嫩aⅴ一区二区三区四区| 国产在线视频一区二区| 老司机精品视频导航| 日韩电影在线一区二区| 亚洲成人黄色影院| 亚洲成在线观看| 亚洲成人先锋电影| 三级精品在线观看| 日韩黄色免费电影| 久久国产成人午夜av影院| 久久爱www久久做| 久久99最新地址| 国产高清在线精品| www.av亚洲| av中文字幕一区| 在线免费观看一区| 欧美精三区欧美精三区| 3atv在线一区二区三区| 日韩一区二区电影网| 日韩精品专区在线| 久久九九久久九九| 国产精品久线在线观看| 综合久久久久久久| 午夜激情一区二区三区| 免费成人性网站| 国产福利91精品一区二区三区| 波多野结衣的一区二区三区| 色综合天天在线| 久久九九久精品国产免费直播| 精品国产一区二区亚洲人成毛片| 久久精品一区二区三区不卡 | 欧美一级黄色录像| 欧美刺激午夜性久久久久久久| 日韩精品最新网址| 国产精品久久久久久亚洲伦| 一区二区三区四区高清精品免费观看 | 亚洲福利电影网| 日本aⅴ亚洲精品中文乱码| 久久国产精品99精品国产| 成人一级视频在线观看| 色婷婷激情一区二区三区| 欧美日韩国产bt| 国产视频亚洲色图| 一区二区久久久久| 久久国产生活片100| 972aa.com艺术欧美| 777xxx欧美| 国产精品视频免费看| 亚洲高清视频在线| 国产不卡在线视频| 91极品视觉盛宴| 精品久久国产字幕高潮| 亚洲欧洲日本在线| 久久99热狠狠色一区二区| 成人av在线资源网| 91精品国产综合久久久蜜臀粉嫩 | 3d成人动漫网站| 国产精品亲子伦对白| 午夜精品久久久久久久久| 不卡高清视频专区| 欧美成人精品3d动漫h| 一区二区高清免费观看影视大全| 久久精品国产一区二区三| 色视频欧美一区二区三区| 精品国产乱码久久久久久蜜臀 | 蜜臀精品久久久久久蜜臀| 成人夜色视频网站在线观看| 欧美精品在线视频| 专区另类欧美日韩| 国产69精品久久99不卡| 7777精品伊人久久久大香线蕉超级流畅 | 久久精品欧美一区二区三区麻豆| 亚洲精品水蜜桃| 国产高清成人在线| 日韩视频一区二区| 亚洲综合偷拍欧美一区色| 国产成人精品一区二区三区四区 | 久久99国产精品免费网站| 欧美在线小视频| 一区视频在线播放| 国产成人一级电影| 26uuu亚洲婷婷狠狠天堂| 丝袜美腿亚洲一区| 欧美亚州韩日在线看免费版国语版| 国产日韩欧美麻豆| 激情欧美日韩一区二区| 日韩一区二区免费在线电影| 亚州成人在线电影| 日本高清不卡aⅴ免费网站| 国产精品萝li| 不卡av在线网| 中文字幕一区二区三区视频| 国产91高潮流白浆在线麻豆| 欧美精品一区二区三区久久久| 日韩和的一区二区| 在线不卡中文字幕| 天天影视涩香欲综合网| 欧美影院一区二区| 亚洲电影欧美电影有声小说| 欧洲在线/亚洲| 亚洲高清免费视频| 欧美三电影在线| 日韩不卡一区二区三区| 91精品国产色综合久久不卡电影| 婷婷成人激情在线网| 制服视频三区第一页精品| 青草国产精品久久久久久| 91精品国产丝袜白色高跟鞋| 蜜臀av性久久久久蜜臀av麻豆 | 欧美乱熟臀69xxxxxx| 日本在线不卡一区| 精品对白一区国产伦| 国产成人综合在线| 中文字幕一区视频| 欧美在线一二三四区| 日本视频免费一区| 国产亚洲精品免费| 91丝袜呻吟高潮美腿白嫩在线观看| 一区二区三区中文字幕| 欧美嫩在线观看| 激情五月婷婷综合| 亚洲三级电影全部在线观看高清| 在线观看一区日韩| 麻豆精品一二三| 国产日韩精品一区二区三区| 色婷婷综合久久久中文字幕| 亚洲国产另类av| 欧美成人女星排行榜| 成人精品电影在线观看| 亚洲一区免费视频| 精品久久人人做人人爰| aa级大片欧美| 青娱乐精品视频在线| 国产精品乱人伦中文| 欧美喷潮久久久xxxxx| 风间由美一区二区av101| 一区二区三区在线影院|