LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-06-2009, 06:39 AM   #1
SavoTU
Member
 
Registered: Apr 2005
Distribution: Slackware64 Current
Posts: 199

Rep: Reputation: 40
Permissions help


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?

thanks

Sav
 
Old 08-06-2009, 06:45 AM   #2
Ramurd
Member
 
Registered: Mar 2009
Location: Rotterdam, the Netherlands
Distribution: Slackwarelinux
Posts: 703

Rep: Reputation: 111Reputation: 111
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?
 
Old 08-06-2009, 06:58 AM   #3
SavoTU
Member
 
Registered: Apr 2005
Distribution: Slackware64 Current
Posts: 199

Original Poster
Rep: Reputation: 40
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
 
Old 08-06-2009, 07:31 AM   #4
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
Quote:
Originally Posted by SavoTU View Post

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
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
 
Old 08-06-2009, 07:54 AM   #5
Ramurd
Member
 
Registered: Mar 2009
Location: Rotterdam, the Netherlands
Distribution: Slackwarelinux
Posts: 703

Rep: Reputation: 111Reputation: 111
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.
 
Old 08-06-2009, 08:00 AM   #6
Ramurd
Member
 
Registered: Mar 2009
Location: Rotterdam, the Netherlands
Distribution: Slackwarelinux
Posts: 703

Rep: Reputation: 111Reputation: 111
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.
 
Old 08-06-2009, 08:30 AM   #7
SavoTU
Member
 
Registered: Apr 2005
Distribution: Slackware64 Current
Posts: 199

Original Poster
Rep: Reputation: 40
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.

Thanks again

Sav.
 
Old 08-06-2009, 08:40 AM   #8
Ramurd
Member
 
Registered: Mar 2009
Location: Rotterdam, the Netherlands
Distribution: Slackwarelinux
Posts: 703

Rep: Reputation: 111Reputation: 111
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...
 
Old 08-06-2009, 03:12 PM   #9
SavoTU
Member
 
Registered: Apr 2005
Distribution: Slackware64 Current
Posts: 199

Original Poster
Rep: Reputation: 40
I would usaly look a little better than i did today but was in a hurry, why is it always when your in a rush?

I was trying to get opera reinstalled as it has all my banking details and doesn't seem to be loading. I will have to look into that now im back.

Thanks again
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
File permissions v. directory permissions Completely Clueless Linux - Newbie 7 07-09-2009 08:33 AM
Help with permissions Rustylinux AIX 2 02-17-2007 09:01 AM
file permissions OK, but command permissions? stabu Linux - General 2 10-05-2005 12:00 PM
permission ... permissions .... permissions alaios Linux - General 1 05-31-2005 04:16 AM
getting a directory's permissions and creating a new one with the same permissions newbie1000101 Programming 1 04-10-2004 12:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration