Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Komisches Problem mit sudo
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German)
View previous topic :: View next topic  
Author Message
l3u
Advocate
Advocate


Joined: 26 Jan 2005
Posts: 2540
Location: Konradsreuth (Germany)

PostPosted: Sat Feb 08, 2014 7:48 pm    Post subject: Komisches Problem mit sudo Reply with quote

Ich habe gerade einen Rechner neu aufgesetzt (evtl. hakt es da also hier und da noch ein bisschen). Jetzt habe ich Problem mit sudo, was ich mir nicht erklären kann.

Auf dem Rechner soll eine virtuelle Maschine mit Qemu laufen. Die kann ich auch als root ganz normal starten. Jetzt würde ich gerne die virtuelle Maschine mit einem Script starten, was ein normaler User ohne Passworteingabe mittels sudo starten kann.

Ein entsprechendes Script habe ich angelegt (/usr/local/bin/launch_server), und wenn ich das als root starte, dann startet auch die virtuelle Maschine normal.

Wenn ich das Script mit "su -c /usr/local/bin/launch_server" starte, dann startet die virtuelle Maschine auch problemlos, aber man muss natürlich das root-Passwort eingeben.

Jetzt will ich das Script ja aber per sudo starten, damit man kein Passwort eingeben muss. Deswegen habe ich das auch per visudo ermöglicht mit
Code:
%wheel ALL=(ALL) NOPASSWD: /usr/local/bin/launch_server

Wenn ich jetzt aber das Script mittels "sudo /usr/local/bin/launch_server" starte, dann bekomme ich folgende Fehlermeldung:
Code:
(qemu) No protocol specified
Could not initialize SDL(No available video device) - exiting

aber warum?! Über sudo wird doch das Script auch als root ausgeführt!


Last edited by l3u on Sun Feb 09, 2014 2:04 am; edited 1 time in total
Back to top
View user's profile Send private message
firefly
Watchman
Watchman


Joined: 31 Oct 2002
Posts: 5165

PostPosted: Sat Feb 08, 2014 8:04 pm    Post subject: Reply with quote

Scheinbar gehen dabei einige env Einstellungen verloren.
AFAIK filtert sudo die env vars um sicherheitsprobleme zu vermeiden.
Siehe auch: http://askubuntu.com/questions/270006/why-user-should-never-use-normal-sudo-to-start-graphical-application
_________________
Ein Ring, sie zu knechten, sie alle zu finden,
Ins Dunkel zu treiben und ewig zu binden
Im Lande Mordor, wo die Schatten drohn.
Back to top
View user's profile Send private message
l3u
Advocate
Advocate


Joined: 26 Jan 2005
Posts: 2540
Location: Konradsreuth (Germany)

PostPosted: Sun Feb 09, 2014 2:04 am    Post subject: Reply with quote

Dann wird das wohl nichts werden mit sudo …
Back to top
View user's profile Send private message
Christian99
Veteran
Veteran


Joined: 28 May 2009
Posts: 1668

PostPosted: Sun Feb 09, 2014 1:32 pm    Post subject: Reply with quote

du könntest die virtuelle Maschine ohne Fenster starten und dich dann über vnc oder so verbinden. wenn kein fenster aufgemacht wird gibts deswegen auch keine Probleme mit sudo. Ich weiß nur nicht wie das mit qemu funktioniert, bin mir aber sicher, dass es so oder so ähnlich geht.
Back to top
View user's profile Send private message
kernelOfTruth
Watchman
Watchman


Joined: 20 Dec 2005
Posts: 6111
Location: Vienna, Austria; Germany; hello world :)

PostPosted: Sun Feb 09, 2014 2:15 pm    Post subject: Reply with quote

hm,

gksu bzw. gksudo versucht ?


wenn was nicht gescheit klappt (via sudo) starte ich ein gnome-terminal via gksudo und fahre dann von dort fort


alternativ: sudo -i ?
_________________
https://github.com/kernelOfTruth/ZFS-for-SystemRescueCD/tree/ZFS-for-SysRescCD-4.9.0
https://github.com/kernelOfTruth/pulseaudio-equalizer-ladspa

Hardcore Gentoo Linux user since 2004 :D
Back to top
View user's profile Send private message
l3u
Advocate
Advocate


Joined: 26 Jan 2005
Posts: 2540
Location: Konradsreuth (Germany)

PostPosted: Sun Feb 09, 2014 3:44 pm    Post subject: Reply with quote

Ich hab jetzt verschiedenes ausprobiert, und mich doch dazu entschlossen, die virtuelle Maschine normal als User zu starten. damit gibt’s dann doch die wenigsten Probleme. Natürlich zu dem Preis, dass der eingeloggte User sie aus Versehen löschen könnte. Aber was soll’s … ;-)
Back to top
View user's profile Send private message
bbgermany
Veteran
Veteran


Joined: 21 Feb 2005
Posts: 1844
Location: Oranienburg/Germany

PostPosted: Mon Feb 10, 2014 9:21 am    Post subject: Reply with quote

Hi,

wenn das eine qemu-kvm Maschine ist, könntest du doch libvirtd verwenden. Das funktioniert sehr zuverlässig.

MfG. Stefan
_________________
Desktop: Ryzen 5 5600G, 32GB, 2TB, RX7600
Notebook: Dell XPS 13 9370, 16GB, 1TB
Server #1: Ryzen 5 Pro 4650G, 64GB, 16.5TB
Server #2: Ryzen 4800H, 32GB, 22TB
Back to top
View user's profile Send private message
l3u
Advocate
Advocate


Joined: 26 Jan 2005
Posts: 2540
Location: Konradsreuth (Germany)

PostPosted: Mon Feb 10, 2014 11:20 am    Post subject: Reply with quote

Ist es, aber ich starte die VM lieber „zu Fuß“ mit einem einfachen Script. Tut alles, was ich will, und ich habe keinen weiteren Abstraktionslayer, den ich eigentlich nicht brauche. Ist auch die einzige VM, die läuft.
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3921
Location: Hamburg

PostPosted: Mon Feb 10, 2014 5:18 pm    Post subject: Reply with quote

Code:
sudo su - username -c "command sequence"
dann sollte auch das komplette env des username gesourced werden.
Back to top
View user's profile Send private message
l3u
Advocate
Advocate


Joined: 26 Jan 2005
Posts: 2540
Location: Konradsreuth (Germany)

PostPosted: Mon Feb 10, 2014 5:59 pm    Post subject: Reply with quote

Aber wenn ich per sudo su aufrufe, dann muss ich ja trotzdem ein Passwort eingeben, oder?! Bzw. dann kann man doch gleich su nehmen, oder?
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3921
Location: Hamburg

PostPosted: Mon Feb 10, 2014 6:05 pm    Post subject: Reply with quote

l3u wrote:
Aber wenn ich per sudo su aufrufe, dann muss ich ja trotzdem ein Passwort eingeben, oder?! Bzw. dann kann man doch gleich su nehmen, oder?
Nein, wenn entweder in /etc/sudoers etwas in dieser Art steht :
Code:

## Same thing without a password
%wheel ALL=(ALL) NOPASSWD: ALL
und der Nutzer zur Gruppe wheel hinzugefügt wurde oder aber Einträge der Art
Code:
ALL ALL=(root) NOPASSWD: /path/to/script
gemacht werden.
Back to top
View user's profile Send private message
l3u
Advocate
Advocate


Joined: 26 Jan 2005
Posts: 2540
Location: Konradsreuth (Germany)

PostPosted: Mon Feb 10, 2014 6:56 pm    Post subject: Reply with quote

Werd ich mal testen. Danke für den Tip!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum