public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
* su: -l and -p should not be used together
@ 2013-05-23 10:57 Bernhard Voelker
  2013-05-29  9:40 ` Karel Zak
  0 siblings, 1 reply; 4+ messages in thread
From: Bernhard Voelker @ 2013-05-23 10:57 UTC (permalink / raw)
  To: util-linux@vger.kernel.org; +Cc: 10317

tag 10317 wontfix
close 10317
stop

A while ago, there has been a bug report to coreutils regarding
the unlucky use of the -p and the -l option (or a bare "-") with su:
  http://bugs.gnu.org/10317

As su is not part of coreutils anymore, I'm hereby closing the bug
there, and forward this issue to util-linux where su is now maintained.

@Karel:
do you think it's worth a warning/error?
However, the agreement was that the behaviour should at least
be documented.

Have a nice day,
Berny


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: su: -l and -p should not be used together
  2013-05-23 10:57 su: -l and -p should not be used together Bernhard Voelker
@ 2013-05-29  9:40 ` Karel Zak
  2013-05-29  9:55   ` Bernhard Voelker
  0 siblings, 1 reply; 4+ messages in thread
From: Karel Zak @ 2013-05-29  9:40 UTC (permalink / raw)
  To: Bernhard Voelker; +Cc: util-linux@vger.kernel.org, 10317

On Thu, May 23, 2013 at 12:57:05PM +0200, Bernhard Voelker wrote:
> A while ago, there has been a bug report to coreutils regarding
> the unlucky use of the -p and the -l option (or a bare "-") with su:
>   http://bugs.gnu.org/10317
> 
> As su is not part of coreutils anymore, I'm hereby closing the bug
> there, and forward this issue to util-linux where su is now maintained.
> 
> @Karel:
> do you think it's worth a warning/error?
> However, the agreement was that the behaviour should at least
> be documented.

Thanks for the report, I have added note to the man page as well as
warning to the code.

    Karel

>From 3e5c0a2db233b726ca80d37aad9eeca8bae144d4 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 29 May 2013 11:32:58 +0200
Subject: [PATCH] su: ignore --preserve-environment, it's mutually exclusive to
 --login

Addresses: http://bugs.gnu.org/10317
Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
---
 login-utils/su-common.c | 5 +++++
 login-utils/su.1        | 1 +
 2 files changed, 6 insertions(+)

diff --git a/login-utils/su-common.c b/login-utils/su-common.c
index ba2a616..a41d015 100644
--- a/login-utils/su-common.c
+++ b/login-utils/su-common.c
@@ -810,6 +810,11 @@ su_main (int argc, char **argv, int mode)
       ++optind;
     }
 
+  if (simulate_login && !change_environment) {
+    warnx(_("ignore --preserve-environment, it's mutually exclusive to --login."));
+    change_environment = true;
+  }
+
   switch (su_mode) {
   case RUNUSER_MODE:
     if (runuser_user) {
diff --git a/login-utils/su.1 b/login-utils/su.1
index c82b941..eab1a6f 100644
--- a/login-utils/su.1
+++ b/login-utils/su.1
@@ -98,6 +98,7 @@ Preserves the whole environment, ie does not set
 .B USER
 nor
 .BR LOGNAME .
+The option is ignored if the option \fB\-\-login\fR is specified.
 .TP
 \fB\-s\fR \fISHELL\fR, \fB\-\-shell\fR=\fISHELL\fR
 Runs the specified shell instead of the default.  The shell to run is
-- 
1.8.1.4


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: su: -l and -p should not be used together
  2013-05-29  9:40 ` Karel Zak
@ 2013-05-29  9:55   ` Bernhard Voelker
  2013-06-07  9:28     ` Karel Zak
  0 siblings, 1 reply; 4+ messages in thread
From: Bernhard Voelker @ 2013-05-29  9:55 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux@vger.kernel.org, 10317

Hi Karel,

On 05/29/2013 11:40 AM, Karel Zak wrote:
> diff --git a/login-utils/su-common.c b/login-utils/su-common.c
> index ba2a616..a41d015 100644
> --- a/login-utils/su-common.c
> +++ b/login-utils/su-common.c
> @@ -810,6 +810,11 @@ su_main (int argc, char **argv, int mode)
>        ++optind;
>      }
>  
> +  if (simulate_login && !change_environment) {
> +    warnx(_("ignore --preserve-environment, it's mutually exclusive to --login."));
> +    change_environment = true;
> +  }
> +

thanks.

As the change was in su-common.c, this also affects runuser.
I think this should then be documented in runuser.1, too, right?

Have a nice day,
Berny

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: su: -l and -p should not be used together
  2013-05-29  9:55   ` Bernhard Voelker
@ 2013-06-07  9:28     ` Karel Zak
  0 siblings, 0 replies; 4+ messages in thread
From: Karel Zak @ 2013-06-07  9:28 UTC (permalink / raw)
  To: Bernhard Voelker; +Cc: util-linux@vger.kernel.org, 10317

On Wed, May 29, 2013 at 11:55:10AM +0200, Bernhard Voelker wrote:
> As the change was in su-common.c, this also affects runuser.
> I think this should then be documented in runuser.1, too, right?

 Good point, fixed.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-06-07  9:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-23 10:57 su: -l and -p should not be used together Bernhard Voelker
2013-05-29  9:40 ` Karel Zak
2013-05-29  9:55   ` Bernhard Voelker
2013-06-07  9:28     ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox