LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-07-2007, 02:03 AM   #1
MQMan
Member
 
Registered: Jan 2004
Location: Los Angeles
Distribution: Slack64 14.1
Posts: 581

Rep: Reputation: 38
"su -s /bin/bash ..." works everywhere except Slack


This is a follow up to this thread, but I thought I'd post it here, as after some experimentation, it only fails to work on Slack.

I was trying to get daemon from /etc/rc.d/init.d/functions to work. Initially this failed, because it uses runuser, which isn't installed in Slack.

After firing up an old RH I have as a VMWare image, hoping to snag a copy of runuser, I found that this version of RH didn't use it. It used "su -s /bin/bash ..." instead. Great, I thought, even easier. Except it doesn't work in Slack.

As an experiment, I tried the following in a number of distributions, running as root:

su -s /bin/bash - <user> -c 'ls -l ~'

Obviously using a valid <user>. I tried both users that were set up to be able to login, and also users that were setup with various variations of "/sbin/nologin", and similar.

On RH, Ubuntu live CD, and Knoppix live CD, this worked every time.

However, on Slack, all it does is load a 2nd copy of the shell, and doesn't switch user, or execute the command.

Why is Slack different, and how can I get it to behave like other distros.

Cheers.
 
Old 10-07-2007, 04:01 AM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Are they the same version? For example:

Code:
$ su --version
su (GNU coreutils) 5.97
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.
 
Old 10-07-2007, 04:41 AM   #3
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 47
This works fine for me:
Code:
su - <user> -c "/bin/bash -c ls -l ~"
 
Old 10-07-2007, 04:43 AM   #4
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 47
or even (since bash is the default shell)
Code:
su - <user> -c ls -l ~
 
Old 10-07-2007, 01:41 PM   #5
MQMan
Member
 
Registered: Jan 2004
Location: Los Angeles
Distribution: Slack64 14.1
Posts: 581

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by uselpa View Post
This works fine for me:
Code:
su - <user> -c "/bin/bash -c ls -l ~"
Great, thanks. But that's a strange syntax, and not the one that's supposed to work. I'd still like to know why Slack is treating this differently than the other distros.

Quote:
Originally Posted by uselpa View Post
or even (since bash is the default shell)
Except I want to run a program as a user who doesn't have a default shell. Which gives me this:
Code:
root@The-Tardis:~# su - slimserver -c '/bin/bash -c ls -l ~'
No shell
So, that trick still doesn't do what I need.

And this is the version I get on Slack:
Code:
root@The-Tardis:~# su --version
GNU bash, version 3.1.17(2)-release (i486-slackware-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
Which looks like the bash version, not su.

Sorry, should have mentioned this is Slack 12. I just noticed my profile is out of date.

Cheers.

Last edited by MQMan; 10-07-2007 at 01:55 PM.
 
Old 10-07-2007, 02:45 PM   #6
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 47
--version is not an known argument to su, so it fowards it to bash, which accepts --version and acts accordingly.

In Slackware 12, /bin/su is part of the shadow-4.0.3-i486-14 package.

As for a user without a default shell, I assume you have set it to /bin/false? Indeed that doesn't seem to work. Why is that a requirement?
 
Old 10-07-2007, 05:33 PM   #7
MQMan
Member
 
Registered: Jan 2004
Location: Los Angeles
Distribution: Slack64 14.1
Posts: 581

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by uselpa View Post
--version is not an known argument to su, so it fowards it to bash, which accepts --version and acts accordingly.
So why did it work for macemoneta above. Plus, it works in my VMWare version of RH.

Quote:
Originally Posted by uselpa View Post
In Slackware 12, /bin/su is part of the shadow-4.0.3-i486-14 package.
Yeah, and looking at the slackbuild scipt, I can't see any "odd" directives that might make it work like this.

Hmmmmm. But, I also noticed that for other systems, it's part of coreutils. Maybe a completely different version. I'll check that later, as I don't have time now.

Quote:
Originally Posted by uselpa View Post
As for a user without a default shell, I assume you have set it to /bin/false? Indeed that doesn't seem to work. Why is that a requirement?
That particular user is set up with /sbin/nologin. I also tried a user that was set up as /bin/false. Still launched a 2nd shell.

It's the way that slimserver installs itself, to allow it to run under it's own account, but not let anyone log in. When I first hit this issue, and stated Googling around, I found it was used like this for a number of packages.

Cheers.
 
Old 10-08-2007, 03:33 AM   #8
arcanex
Member
 
Registered: Mar 2007
Posts: 41

Rep: Reputation: 15
I just tried 'su --version' and it didn't work (I got bash's version instead). I am running Slack 10.2 btw.

So it would seem like the version of 'su' that Slackware ships with is not the same as the one in GNU coreutils. I don't know why the GNU 'su' doesn't ship with the Slackware coreutils package, but if you need the '-s' option in Slackware (I use it myself in some RHEL scripts), you're probably gonna need to get the GNU version of 'su', as the one in Slackware doesn't support it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
LFS 6.2 Ch. 6.14 - 2nd Coreutils test returns "/bin.bash: No such file or directory" 0graham0 Linux From Scratch 2 08-23-2007 06:32 PM
(bash) echo "#!/bin/bash" event not found - trying to generate profiles automatically jimieee Programming 9 05-03-2006 10:24 AM
problem "make"ing gtk+ "/usr/bin/env: perl -w" caid Linux - Newbie 8 07-29-2005 04:51 AM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration