| Summary: | buggy preinstall scriptlet | ||
|---|---|---|---|
| Product: | Sisyphus | Reporter: | (GalaxyMaster) <galaxy4public> |
| Component: | jetty | Assignee: | viy <viy> |
| Status: | CLOSED FIXED | QA Contact: | qa-sisyphus |
| Severity: | normal | ||
| Priority: | P3 | CC: | viy |
| Version: | unstable | ||
| Hardware: | all | ||
| OS: | Linux | ||
Thank you very much for the report, fixed in jetty6-6.1.26-alt8_1jpp6.src.rpm and I will be more careful from now on. Well, it's not there yet :(. The latest package has the following scriptlets:
===
[root@galaxy ~]# rpm -q --scripts jetty
preinstall scriptlet (through /bin/sh):
groupadd -r jetty || :
# Use /bin/sh so init script will start properly.
useradd -r -s /bin/sh -d /usr/share/jetty -M \
-g jetty jetty || :
postinstall scriptlet (through /bin/sh):
[ -x /sbin/chkconfig ] && /sbin/chkconfig --add jetty
preuninstall scriptlet (through /bin/sh):
if [ $1 = 0 ]; then
[ -f /var/lock/subsys/jetty ] && /etc/rc.d/init.d/jetty stop
[ -f /etc/rc.d/init.d/jetty -a -x /sbin/chkconfig ] && /sbin/chkconfig --del jetty
/usr/sbin/userdel jetty >> /dev/null 2>&1 || :
fi
postuninstall scriptlet (through /bin/sh):
#userdel jetty &>/dev/null || :
#groupdel jetty &>/dev/null || :
[root@galaxy ~]#
===
While the following would be much better:
===
[root@galaxy ~]# rpm -q --scripts jetty
preinstall scriptlet (through /bin/sh):
getent group jetty >/dev/null || groupadd -r jetty || :
# Use /bin/sh so init script will start properly.
getent passwd jetty >/dev/null || \
useradd -r -s /bin/sh -d /usr/share/jetty -M \
-g jetty jetty || :
postinstall scriptlet (through /bin/sh):
[ -x /sbin/chkconfig ] && /sbin/chkconfig --add jetty
preuninstall scriptlet (through /bin/sh):
if [ $1 = 0 ]; then
[ -f /var/lock/subsys/jetty ] && /etc/rc.d/init.d/jetty stop
[ -f /etc/rc.d/init.d/jetty -a -x /sbin/chkconfig ] && /sbin/chkconfig --del jetty
fi
postuninstall scriptlet (through /bin/sh):
if [ $1 = 0 ]; then
/usr/sbin/userdel jetty || :
fi
[root@galaxy ~]#
===
The changes are:
* in preinstall: add group/user only if it's not already defined;
* in preinstall: do not delete the user there, since "pre*" scriptlets may fail and we will end up with unowned files;
* in postinstall: delete user here under the condition that this was the last package (well, we still can end up with the unowned files/dirs, but at this stage there is nothing we can do about it).
ok, thanks, will fix in jetty-8.1.5 (next week, I guess) I remember about that bug, but jetty 8.1.5 is delayed (It still does not build). |
The jetty6 package has definitely a buggy preinstall scriptlet: === [root@galaxy ~]# rpm -q --scripts jetty6 preinstall scriptlet (through /bin/sh): /usr/sbin/groupadd -r -r jetty &>/dev/null || : # Use /bin/sh so init script will start properly. /usr/sbin/useradd -r -s /bin/sh -d /usr/share/jetty6 -M \ -r jetty &>/dev/null || : === Although the first command works (despite the redundant "-r"), the second doesn't. The useradd command complains that the jetty group already exists and that if we want to assign the group to this user we need to use '-g jetty', but nobody sees it since everything is redirected to /dev/null. BTW< I believe redirecting everything to /dev/null is a very bad idea for a pre/post scriptlets. I'd prefer to see >/dev/null here with error messages still directed to the console.