LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
Search this Thread
Old 05-24-2005, 05:18 AM   #1
cefs99
LQ Newbie
 
Registered: May 2005
Distribution: redhat EL
Posts: 7

Rep: Reputation: 0
wrong login shell prevent root login


Hi,

When I play with my home linux and place a wrong shell for root user in the /etc/passwd file like this:

root:.....:/sbin/wrongshell

now when I want to be root via su, it display following msg:

su: using restricted shell /sbin/wrongshell
su: /sbin/wrongshell: No such file or directory


even the command:

su --shell=/bin/bash

doesn't work since it still need to call the /bin/wrongshell after login.

How can I override the /sbin/wrongshell without reboot and into the single user mode?


Tks,

Hong
 
Old 05-24-2005, 05:40 AM   #2
oneandoneis2
Senior Member
 
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460

Rep: Reputation: 46
Have you got sudo installed? Or any write access to /sbin? If so, create a symlink to /bin/bash at the /sbin/wrongshell location:

ln -sf /bin/bash /sbin/wrongshell
 
Old 05-24-2005, 07:42 AM   #3
cefs99
LQ Newbie
 
Registered: May 2005
Distribution: redhat EL
Posts: 7

Original Poster
Rep: Reputation: 0
Question

Hi,

Neither I can execute with sudo nor the /sbin directory is writable for me.

I just wonder, since su --shell allow me to specifiy a shell to use instead of the shell specified in /etc/passwd, is it possible for me to tell "su" to ignore the shell specified in /etc/passwd?


Tks,

Hong
 
Old 05-28-2006, 10:31 PM   #4
Stephnet
LQ Newbie
 
Registered: May 2006
Posts: 7

Rep: Reputation: 0
The Man Page for SU,




NAME
su - Change user ID or become super-user

SYNOPSIS
su [OPTS] [-] [username [ARGS]]

DESCRIPTION
su is used to become another user during a login session. Invoked
without a username, su defaults to becoming the super user. The
optional argument - may be used to provide an environment similiar to
what the user would expect had the user logged in directly.

The user will be prompted for a password, if appropriate. Invalid
passwords will produce an error message. All attempts, both valid and
invalid, are logged to detect abuses of the system.

An optional command can be executed. This is done by the shell speci-
fied in /etc/passwd for the target user unless the -s or -m options are
used. Any arguments supplied after the username will be passed to the
invoked shell (shell must support the -c command line option in order
for a command to be passed to it).

Unless the -m or -p options are used, the current environment is passed
to the new shell with alterations. The value of $PATH is reset to
/bin:/usr/bin for normal users, or /sbin:/bin:/usr/sbin:/usr/bin for
the super user. This may be changed with the ENV_PATH and ENV_SUPATH
definitions in /etc/login.defs. $IFS, if is set, is reset to contain
space, tab, and newline. $USER is set to the name of the target user,
$HOME is set to the home directory of the target user, and $SHELL is
set to the shell of the target user. When using the -m or -p options,
the user's environment is not changed.

A subsystem login is indicated by the presense of a "*" as the first
character of the login shell. The given home directory will be used as
the root of a new filesystem which the user is actually logged into.

OPTIONS
- make this a login shell

-c, --commmand=<command>
pass command to the invoked shell using its -c option

-m, -p, --preserve-environment
do not reset environment variables, and keep the same shell

-s, --shell=<shell>
use shell instead of the default in /etc/passwd
NOTES
The -m, -p and -s options are restricted by the target user's shell
being listed in /etc/shells. If it's not listed, then it's assumed to
be a restricted account, a normal su is performed, and those options
are ignored silently.

A subsystem login is indicated by the presense of a "*" as the first
character of the login shell. The given home directory will be used as
the root of a new filesystem which the user is actually logged into.

Much of the behavior of this command can be altered via its pam config-
uration - see pam(7)

CAVEATS
This version of su has many compilation options, only some of which may
be in use at any particular site.

FILES
/etc/passwd - user account information
/etc/shadow - encrypted passwords and age information
/etc/shells - valid user shells
$HOME/.profile - initialization script for default shell
 
Old 05-31-2006, 08:28 AM   #5
linuxmanju
Member
 
Registered: Sep 2003
Location: India
Distribution: Debian
Posts: 50

Rep: Reputation: 15
reboot and in the grup boot prompt type
linux init=/bin/bash
that will take you into the single user raw mode.
edit /etc/passwd file to refflect /bin/bash as the login shell and reboot

Regards
Manjunath
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to check in a script whether the shell is login or non login? frankie_DJ Programming 5 09-06-2005 06:01 AM
How to login root shell satimis Linux From Scratch 7 07-11-2005 08:07 PM
changed the login shell in /etc/passwd to the wrong path infamous41md Solaris / OpenSolaris 3 07-03-2004 07:32 PM
Allow ProFTP login but prevent local login? sorrodos Linux - Networking 2 06-23-2004 01:56 PM
Unable to launch X apps with non login root shell kc00l Slackware 2 11-24-2003 03:32 AM


All times are GMT -5. The time now is 01:19 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration