PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : mal wieder sudo



schneevater
15.06.02, 21:10
Hallo,

es geht mal wieder um sudo. Und zwar habe ich folgendes Problem.
Ich möchte das mein User den Befehle "shutdown -h now" ausführen kann.
sudoers sieht folgendermasen aus:

# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#

# Host alias specification

# User alias specification
User_Alias USER=schneevater

# Cmnd alias specification
Cmnd_Alias BOOT=/sbin/shutdown -h now

# Defaults specification

# User privilege specification
root ALL=(ALL) ALL
USER ALL=NOPASSWD:BOOT


# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL

# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

# Samples
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users localhost=/sbin/shutdown -h now

Wenn ich nun z.B. von /home/schneevater aus "sudo shutdown -h now" eingebe, werde ich das erstemal nach einem Passwort gefragt. Nachdem ich das Passwort eingegeben habe, bekomme ich die Meldung das sudo den Befehl shutdown (ohne -h now) nicht finden kann. Wechsel ich nach /sbin und gebe dort "sudo shutdown -h now" ein bzw. aus irgendeinem anderen Verzeichnis "sudo /sbin/shutdown -h now" funktioniert es einwandfrei.
Ich habe es mal mit anderen Befehlen versucht, hat aber auch nichts gebracht.
Was habe ich falsch gemacht??????????? Oder ist das richtig, das ich den kompletten Pfad eingeben muß??

melody lee
15.06.02, 21:25
>Oder ist das richtig, das ich den kompletten Pfad eingeben muß??
Ich bin da zwar kein Freund von, aber u könntest alternativ auch /sbin an die PATH-Variable anhängen. (.bash_profile)
Wenn es aber nur darum geht, die Kiste runterzufahren - wozu den Umweg, wenn es auch mit [ctrl]+[alt]+[del] geht? Ist doch viel einfacher.

geronet
15.06.02, 21:27
Es ist richtig, dass man den kompletten Pfad angeben muss. Kann man als Sicherheit betrachten, damit man als root immer die "richtigen" Programme startet die man auch wirklich starten will.


Wem das nicht gefällt der kann in der [home]/.bashrc ja dies eintragen:





PATH="$PATH:/usr/sbin:/sbin"





Zu deinem anderen Problem mit shutdown:





Du kannst das auch ohne sudo machen, wenn du in der /etc/inittab statt der Zeile





ca::ctrlaltdel:/sbin/shutdown -t3 -r now





diese einträgst:





ca::ctrlaltdel:/sbin/shutdown -a -t3 -r now





Das "-a" sagt in diesem Fall das hier aus:



ACCESS CONTROL
shutdown can be called from init(8) when the magic keys
CTRL-ALT-DEL are pressed, by creating an appropriate entry
in /etc/inittab. This means that everyone who has physical access to
the con_ sole keyboard can shut the system down. To prevent
this, shutdown can check to see if an autho_ rized user is
logged in on one of the virtual consoles. If shutdown is called with the
-a argu_ ment (add this to the invocation of shutdown in
/etc/inittab), it checks to see if the file /etc/shutdown.allow
is present. It then compares the login names in that file with the list of
people that are logged in on a virtual console (from
/var/run/utmp). Only if one of those autho_ rized users or root is
logged in, it will proceed. Otherwise it will write the message
shutdown: no authorized users logged in to the (physical)
system console. The format of /etc/shutdown.allow is one user name
per line. Empty lines and comment lines (prefixed by a #) are
allowed. Currently there is a limit of 32 users in this
file.




Grüsse, Stefan

schneevater
15.06.02, 21:59
Hallo,

danke für die Antworten. Ich denke mal das sudo ein sehr nützliches Werkzeug ist, das mit dem shutdown, reboot, halt etc. scheint mit die sicherste Methode zu sein sich da einzuarbeiten.
Ich für meinen Teil werde wohl weiter über "su" den Rechner runterfahren. Ist halt Gewohnheit.