id summary reporter owner description type status priority component version resolution keywords cc guest host
11720 Solaris Autostart service can only work for 1st user in staff group => fixed in SVN kburtch "
First:
The use of ""exec"" in smf-vboxautostart.sh breaks the loop through the users as it replaces the current process with the ""su"" process. It also prevents the immediately following exit status check from functioning.
Second:
The smf-vboxautostart.sh script loops over the ""staff"" Unix group instead of the ""vboxuser"" Unix group to determine which users to look for to start autostart-enabled VMs.
The use of the ""vboxuser"" group makes more sense than ""staff"" as not all companies use ""staff"" for their users, and the ""vboxuser"" group is a required group for anyone running VirtualBox anyways.
Third:
Looping through ""logins -g ''group''"" includes 5 columns of data (including the GECOS field), so it will be looping over UID, group, GID, first name, last name, etc. as well as the username. At a minimum, it should be piped through ""cut -d' ' -f1"" to strip out the irrelevant data.
{{{
# Get all users
for VW_USER in `logins -g staff`
do
exec su - ""$VW_USER"" -c ""/opt/VirtualBox/VBoxAutostart --background --start --config \""$VW_CONFIG\"" --logrotate \""$VW_ROTATE\"" --logsize \""$VW_LOGSIZE\"" --loginterval \""$VW_LOGINTERVAL\""""
VW_EXIT=$?
if [ $VW_EXIT != 0 ]; then
echo ""VBoxAutostart failed with $VW_EXIT.""
VW_EXIT=1
break
fi
done
}}}
I suggest changing it to the following (diff attached):
{{{
for VW_USER in `logins -g vboxuser | cut -d' ' -f1`
do
su - ""$VW_USER"" -c ""/opt/VirtualBox/VBoxAutostart --background --start --config \""$VW_CONFIG\"" --logrotate \""$VW_ROTATE\"" --logsize \""$VW_LOGSIZE\"" --loginterval \""$VW_LOGINTERVAL\""""
VW_EXIT=$?
if [ $VW_EXIT != 0 ]; then
echo ""VBoxAutostart failed with $VW_EXIT.""
VW_EXIT=1
break
fi
done
}}}
The above fixes all three problems: autostart VMs not starting unless you're 1st in the list; users not in ""staff"" group not having VMs started); and attempting to su to groups, numbers, etc.
(diff attached)
Note the diff also contains a clarification of error output for the top section where it checks if a file is executable, then if it exists. I reversed those and changed the error to make more sense.
{{{
--- /opt/VirtualBox/smf-vboxautostart.sh.orig Fri Apr 12 12:19:08 2013
+++ /opt/VirtualBox/smf-vboxautostart.sh Mon Apr 15 19:23:31 2013
@@ -24,13 +24,13 @@
case $VW_OPT in
start)
- if [ ! -x /opt/VirtualBox/VBoxAutostart ]; then
+ if [ ! -f /opt/VirtualBox/VBoxAutostart ]; then
echo ""ERROR: /opt/VirtualBox/VBoxAutostart does not exist.""
return $SMF_EXIT_ERR_CONFIG
fi
- if [ ! -f /opt/VirtualBox/VBoxAutostart ]; then
- echo ""ERROR: /opt/VirtualBox/VBoxAutostart does not exist.""
+ if [ ! -x /opt/VirtualBox/VBoxAutostart ]; then
+ echo ""ERROR: /opt/VirtualBox/VBoxAutostart is not executable.""
return $SMF_EXIT_ERR_CONFIG
fi
@@ -51,9 +51,9 @@
[ -z ""$VW_LOGINTERVAL"" ] && VW_LOGINTERVAL=86400
# Get all users
- for VW_USER in `logins -g staff`
+ for VW_USER in `logins -g vboxuser | cut -d' ' -f1`
do
- exec su - ""$VW_USER"" -c ""/opt/VirtualBox/VBoxAutostart --background --start --config \""$VW_CONFIG\"" --logrotate \""$VW_ROTATE\"" --logsize \""$VW_LOGSIZE\"" --loginterval \""$VW_LOGINTERVAL\""""
+ su - ""$VW_USER"" -c ""/opt/VirtualBox/VBoxAutostart --background --start --config \""$VW_CONFIG\"" --logrotate \""$VW_ROTATE\"" --logsize \""$VW_LOGSIZE\"" --loginterval \""$VW_LOGINTERVAL\""""
VW_EXIT=$?
if [ $VW_EXIT != 0 ]; then
}}}
I started a forum post on this, originally thinking the problem was the use of null arguments to options when calling VBoxAutostart (before I noticed the ""exec""), as VBoxAutostart fails under those conditions.
[https://forums.virtualbox.org/viewtopic.php?f=11&t=55006]
" defect closed major other VirtualBox 4.2.12 fixed autostart solaris smf group other Solaris