Implement the -d' option, which behaves as
-l' but does not change the
current directory. Idea suggested by dsl@ in source-changes.
This commit is contained in:
parent
b4d5e11ffe
commit
ab753cc4ce
@ -30,9 +30,9 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)su.1 8.2 (Berkeley) 4/18/94
|
||||
.\" $NetBSD: su.1,v 1.30 2003/04/24 12:19:06 wiz Exp $
|
||||
.\" $NetBSD: su.1,v 1.31 2003/04/27 08:46:25 jmmv Exp $
|
||||
.\"
|
||||
.Dd April 20, 2003
|
||||
.Dd April 27, 2003
|
||||
.Dt SU 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -40,7 +40,7 @@
|
||||
.Nd substitute user identity
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl Kflm
|
||||
.Op Fl Kdflm
|
||||
.Op Fl c Ar login-class
|
||||
.Op Ar login Op Ar "shell arguments"
|
||||
.Sh DESCRIPTION
|
||||
@ -100,6 +100,10 @@ You may only override the default class if you're already root.
|
||||
See
|
||||
.Xr login.conf 5
|
||||
for details.
|
||||
.It Fl d
|
||||
Same as
|
||||
.Fl l ,
|
||||
but does not change the current directory.
|
||||
.It Fl f
|
||||
If the invoked shell is
|
||||
.Xr csh 1 ,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: su.c,v 1.53 2003/04/25 08:04:14 mycroft Exp $ */
|
||||
/* $NetBSD: su.c,v 1.54 2003/04/27 08:46:26 jmmv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 The Regents of the University of California.
|
||||
@ -44,7 +44,7 @@ __COPYRIGHT(
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)su.c 8.3 (Berkeley) 4/2/94";*/
|
||||
#else
|
||||
__RCSID("$NetBSD: su.c,v 1.53 2003/04/25 08:04:14 mycroft Exp $");
|
||||
__RCSID("$NetBSD: su.c,v 1.54 2003/04/27 08:46:26 jmmv Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -90,12 +90,12 @@ static int kerberos5 __P((char *, char *, int));
|
||||
|
||||
#if defined(KERBEROS) || defined(KERBEROS5)
|
||||
|
||||
#define ARGSTRX "-Kflm"
|
||||
#define ARGSTRX "-Kdflm"
|
||||
|
||||
int use_kerberos = 1;
|
||||
|
||||
#else
|
||||
#define ARGSTRX "-flm"
|
||||
#define ARGSTRX "-dflm"
|
||||
#endif
|
||||
|
||||
#ifndef SUGROUP
|
||||
@ -127,7 +127,7 @@ main(argc, argv)
|
||||
struct timeval tp;
|
||||
#endif
|
||||
uid_t ruid;
|
||||
int asme, ch, asthem, fastlogin, prio;
|
||||
int asme, ch, asthem, fastlogin, prio, gohome;
|
||||
enum { UNSET, YES, NO } iscsh = UNSET;
|
||||
char *user, *shell, *avshell, *username, **np;
|
||||
char *userpass, *class;
|
||||
@ -138,6 +138,7 @@ main(argc, argv)
|
||||
#endif
|
||||
|
||||
asme = asthem = fastlogin = 0;
|
||||
gohome = 1;
|
||||
shell = class = NULL;
|
||||
while ((ch = getopt(argc, argv, ARGSTR)) != -1)
|
||||
switch((char)ch) {
|
||||
@ -151,6 +152,11 @@ main(argc, argv)
|
||||
class = optarg;
|
||||
break;
|
||||
#endif
|
||||
case 'd':
|
||||
asme = 0;
|
||||
asthem = 1;
|
||||
gohome = 0;
|
||||
break;
|
||||
case 'f':
|
||||
fastlogin = 1;
|
||||
break;
|
||||
@ -340,7 +346,7 @@ badlogin:
|
||||
#endif
|
||||
if (p)
|
||||
(void)setenv("TERM", p, 1);
|
||||
if (chdir(pwd->pw_dir) < 0)
|
||||
if (gohome && chdir(pwd->pw_dir) < 0)
|
||||
errx(1, "no directory");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user