SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have just modified a slackbuild script and ran it as root then everything stopped working.
It has changed all permissions to root:root. I have changed my home dir and the /tmp dir but am still not able to start x unless i am root, i just get permission errors does anyone know which files and folders i need to change, and what they should be changed to?
It may help if you can provide the script rather than let everyone guess around which bits are to be set where.
You can copy / paste the code in here, preferably in a "code"-block. It is the first place one should look I suppose, what did the thing I just ran do, that made my system mis-behave?
Secondly, what slackware version are you at? What was the slackbuild script supposed to build? Was this the only thing ran that made your system behave differently, or did you run any other programs/scripts?
Sorry i was fairly sure that it had just changed all permissions and it would be simple.
This is the slackbuild i ran, i had just changed the version and changed it from .bz2.
It extracted all the files then said something along the lines of cannot find install.sh, which is when everything stopped working (eg, couldn't see my desktop, krwire wouldn't work, the pdfs i had open couldn't be seen).
Edit: sorry forgot again im running current.
Code:
#!/bin/sh
PRGNAM=opera
VERSION=9.64
ARCH=i386 # Leave this alone
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}
CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
# If you want Chinese in Opera to not be fugly, set this to "YES",
# otherwise leave it be.
# This can be specified on the command line when calling the build script:
# CHINESE_FIX=YES ./opera.SlackBuild
# Note that this makes Opera use wqy-zenhei as the default font
# for Chinese AND Japanese
CHINESE_FIX=${CHINESE_FIX:-NO}
# Don't bother this - it's for easier manipulation and sed'ing later
TOPDIR=$(tar tf $CWD/$PRGNAM-${VERSION}.gcc4-shared-qt3.i386.tar.bz2 |head -1)
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $TOPDIR
tar xvf $CWD/$PRGNAM-${VERSION}.gcc4-shared-qt3.i386.tar.gz
cd $TOPDIR
chown -R root:root .
chmod -R u+w,go+r-w,a-s .
# No, the --DESTDIR isn't documented. In fact, the presence of OPERADESTDIR
# at the top of install.sh is damn misleading. I shouldn't have to actually
# read the install script to figure out DESTDIR - the --help should show it.
# --rworkman
./install.sh \
--prefix=/usr \
--exec_prefix=/usr/lib/opera-$VERSION \
--sharedir=/usr/share/opera \
--wrapperdir=/usr/bin \
--mandir=/usr/man \
--docdir=/usr/doc/opera-$VERSION \
--plugindir=/usr/lib/mozilla/plugins \
--DESTDIR=$PKG
# Fix a potential security issue (minor, but still) with a hardcoded path to
# the build directory lingering in /usr/bin/opera
# Theoretically, a malicious user looks at that in /usr/bin/opera and later
# recreates the directory and does some unknown havoc. It may very well be
# completely safe and unexploitable and I'm just being Chicken Little here,
# but it's easy enough to fix and I'd rather be safe than sorry. --rworkman
sed -i "s|$TMP/$TOPDIR|/usr/bin/|g" $PKG/usr/bin/opera
# Include config files
mv etc $PKG
mv $PKG/etc/opera6rc $PKG/etc/opera6rc.new
mv $PKG/etc/opera6rc.fixed $PKG/etc/opera6rc.fixed.new
# Add an opera.desktop file and link the icon to /usr/share/pixmaps
mv usr/share/icons usr/share/pixmaps $PKG/usr/share
mkdir -p $PKG/usr/share/applications
install -m 0644 $CWD/opera.desktop $PKG/usr/share/applications
# Add a copy of the build script to the docs
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
# Compress the man page
gzip -9 $PKG/usr/man/man?/*.?
# Strip symbols we don't need
find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh
cd $PKG
# Patch for Chinese font handling
if [ "$CHINESE_FIX" = "YES" ]; then
patch -p0 < $CWD/opera_chinese_font_fix.diff
fi
/sbin/makepkg -p -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.tgz
#!/bin/sh
PRGNAM=opera
VERSION=9.64
ARCH=i386 # Leave this alone
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}
CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
# If you want Chinese in Opera to not be fugly, set this to "YES",
# otherwise leave it be.
# This can be specified on the command line when calling the build script:
# CHINESE_FIX=YES ./opera.SlackBuild
# Note that this makes Opera use wqy-zenhei as the default font
# for Chinese AND Japanese
CHINESE_FIX=${CHINESE_FIX:-NO}
# Don't bother this - it's for easier manipulation and sed'ing later
TOPDIR=$(tar tf $CWD/$PRGNAM-${VERSION}.gcc4-shared-qt3.i386.tar.bz2 |head -1)
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $TOPDIR
tar xvf $CWD/$PRGNAM-${VERSION}.gcc4-shared-qt3.i386.tar.gz
cd $TOPDIR
chown -R root:root .
chmod -R u+w,go+r-w,a-s .
# No, the --DESTDIR isn't documented. In fact, the presence of OPERADESTDIR
# at the top of install.sh is damn misleading. I shouldn't have to actually
# read the install script to figure out DESTDIR - the --help should show it.
# --rworkman
./install.sh \
--prefix=/usr \
--exec_prefix=/usr/lib/opera-$VERSION \
--sharedir=/usr/share/opera \
--wrapperdir=/usr/bin \
--mandir=/usr/man \
--docdir=/usr/doc/opera-$VERSION \
--plugindir=/usr/lib/mozilla/plugins \
--DESTDIR=$PKG
# Fix a potential security issue (minor, but still) with a hardcoded path to
# the build directory lingering in /usr/bin/opera
# Theoretically, a malicious user looks at that in /usr/bin/opera and later
# recreates the directory and does some unknown havoc. It may very well be
# completely safe and unexploitable and I'm just being Chicken Little here,
# but it's easy enough to fix and I'd rather be safe than sorry. --rworkman
sed -i "s|$TMP/$TOPDIR|/usr/bin/|g" $PKG/usr/bin/opera
# Include config files
mv etc $PKG
mv $PKG/etc/opera6rc $PKG/etc/opera6rc.new
mv $PKG/etc/opera6rc.fixed $PKG/etc/opera6rc.fixed.new
# Add an opera.desktop file and link the icon to /usr/share/pixmaps
mv usr/share/icons usr/share/pixmaps $PKG/usr/share
mkdir -p $PKG/usr/share/applications
install -m 0644 $CWD/opera.desktop $PKG/usr/share/applications
# Add a copy of the build script to the docs
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
# Compress the man page
gzip -9 $PKG/usr/man/man?/*.?
# Strip symbols we don't need
find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh
cd $PKG
# Patch for Chinese font handling
if [ "$CHINESE_FIX" = "YES" ]; then
patch -p0 < $CWD/opera_chinese_font_fix.diff
fi
/sbin/makepkg -p -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.tgz
Yikes! Looks like the filename mismatch and a lack of any sort of validation relating to $TOPDIR are the cause here. That code was an accident waiting to happen.
Also, doesn't the two tar commands need a 'j' or 'z' because of the compression?
Last edited by GazL; 08-06-2009 at 07:58 AM.
Reason: removed bit I didn't understand as I do now
most likely cause, as far as I can see right now is that your homedirectory got owned by root; this could be (haven't tested this version of tar in this regard yet) tar tf might not recognize the file as "bzip2" and as such not be able to read TOPDIR from the file. TOPDIR would be empty, resulting in a "cd", going to the homedirectory; it should be root's homedir however.
There are inconsistencies in the name of the tarball: one line you call it a "bz2" another "gz";
Another thing that may have happened, is that all your files got owned by root, leaving you with a system that's pretty damn hard to use at all. A re-install would help you quickest in that case, as it's near impossible to know all the bits; On the other hand... many files may have gotten removed and pretty damn hard to tell righ there wihch that may have been. My guess is that $TOPDIR did not get set correctly.
As GazL said, a filename mismatch and no errorchecking indeed.
I suppose ${TOPDIR} gets empty, resulting in a "cd ", which -by definition- goes to the homedir. How deep the problem will have run is pretty hard to say at this moment; In /tmp a few sockets may have gotten deleted (nothing too horrible in itself, a reboot would fix that as an easy solution) The problems that may have arisen may have run more deeply, and most probably have resulted in removal of inuntended files apart from a few files changed owner / security bits.
See if a reboot gets your computer back on track, otherwise I fear you may have to revert to a reinstall; This should be doable by doing "slackpkg reinstall all" as root, or so I hope... Never tried this, so you may want to consult a few more people first.
I rebooted and then tried to startx as soon as the problem arose, this didn't work so i changed the permissions on my home dir and tmp but kde still refused to start, that's when i posted.
It turns out i just had to logout and back in to get a working system after the permission change.
Thanks for the replies i have checked some files in htdocs and they have the correct permissions also i checked tmp and the extracted files are missing so i hope all is well.
Glad the damage was very limited, things in /tmp ought to be removable, although running programs may have problems with files they created there got missing. A clean /tmp after a reboot should never result in problems, or otherwise the files do not belong there. (For tihs reason /tmp often is a ramdisk)
Hope you learned not to take the name of root in vain :-) As well as be very sure what your script does,before you go try it out as root...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.