diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2018-01-28 10:50:23 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2018-01-28 10:50:23 -0200 |
commit | 0171ddb9708968a25bc4d9dee0427ad24dcc78ff (patch) | |
tree | 7cbd66681ff99a208d99859d90bed4a4618c975a /kvmx-supervise | |
parent | 9903bf0df5dcda03ed1505bef247e84cc4a17ec4 (diff) | |
download | kvmx-0171ddb9708968a25bc4d9dee0427ad24dcc78ff.tar.gz kvmx-0171ddb9708968a25bc4d9dee0427ad24dcc78ff.tar.bz2 |
Make kvmx-supervise work for regular users
Diffstat (limited to 'kvmx-supervise')
-rwxr-xr-x | kvmx-supervise | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/kvmx-supervise b/kvmx-supervise index 72c2cdc..aa0002a 100755 --- a/kvmx-supervise +++ b/kvmx-supervise @@ -33,10 +33,13 @@ VERSION="`$APP_BASE/kvmx version`" # Initialize function __kvmx_supervise_initialize { - if [ "`whoami`" != "root" ]; then - echo "$BASENAME: needs root privileges" - exit 1 - fi + #if [ "`whoami`" != "root" ]; then + # echo "$BASENAME: needs root privileges" + # exit 1 + #fi + + # Put startup code here + true } # Display usage @@ -83,13 +86,23 @@ function kvmx_supervise_call { exit 1 fi - # Operate only with VMs configured with supervise_manage=1 + # When running as root, operate only with VMs configured with supervise_manage=1 # Specify /bin/bash to avoid restricted shells like kvmx-shell - supervise_manage="`su $user -s /bin/bash -c "kvmx config $vm supervise_manage"`" + if [ "`whoami`" == "root" ]; then + supervise_manage="`su $user -s /bin/bash -c "kvmx config $vm supervise_manage"`" + else + supervise_manage="1" + fi # Dispatch if [ "$supervise_manage" == "1" ]; then - su $user -s /bin/bash -c "kvmx ${params[0]} $vm ${params[@]:1}" + if [ "`whoami`" == "root" ]; then + su $user -s /bin/bash -c "kvmx ${params[0]} $vm ${params[@]:1}" + else + if [ "`whoami`" == "$user" ]; then + kvmx ${params[0]} $vm ${params[@]:1} + fi + fi fi } |