Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 07 Dec 2019, 00:48
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
A script to fix Directory Permissions
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [5 Posts]  
Author Message
s243a

Joined: 02 Sep 2014
Posts: 2189

PostPosted: Fri 03 May 2019, 04:33    Post subject:  A script to fix Directory Permissions  

On puppy new directories are created typically as:
user=root, group=spot

and folder read and execute permissions are given to typically user and group. This scheme won't work if either:
1. A user is not in group sport or;
2. The group permission of the folder is root.

So one can run into issues if a folder in either LD_LIBRARY_PATH, PATH or /etc doesn't have both read and execute permission for the folder. If for some reason this occurs (I had issues on TazPup64), here is a script to fix it:

Code:

#!/bin/bash
#
#IFS=: read -r -d '' -a path_array < <(printf '%s:\0' "$MANPATH")
#
_(){
  echo "$*"   
}
CONFIG_DIRS="/etc:" #For some reason we need a caracter to end the aray.
for path_list_name in LD_LIBRARY_PATH PATH CONFIG_DIRS; do
  while IFS=\0 read -r -d '' a_path; do
    if [ -d "$a_path" ] && \
       [ "`stat -c '%U %G' $(_ $a_path)`" = "root root"  ]; then
      chmod 775 $a_path
    fi
  done < <(echo "`eval $(_ echo '$'$path_list_name)`" | tr ':' '\0' )
done
#exit 0
Back to top
View user's profile Send private message Visit poster's website 
rufwoof


Joined: 24 Feb 2014
Posts: 3667

PostPosted: Sat 04 May 2019, 07:28    Post subject:  

I would have thought that you'd want to restrict spot more. Opening up all of those folders like that to spot also opens up potential setuid access and potentially as good as invalidates running internet apps/browser as spot. ???
_________________
( ͡° ͜ʖ ͡°) :wq
Fatdog multi-session usb

echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh
Back to top
View user's profile Send private message 
s243a

Joined: 02 Sep 2014
Posts: 2189

PostPosted: Sat 04 May 2019, 13:03    Post subject:  

rufwoof wrote:
I would have thought that you'd want to restrict spot more. Opening up all of those folders like that to spot also opens up potential setuid access and potentially as good as invalidates running internet apps/browser as spot. ???


The problem is if spot doesn't have exec premission to the etc folder then spot can't do commands like "whoami" because then spot can't read /etc/passwd.

An alternative would be to have spot use a different folder than /etc and either copy, hard-link (or maybe symlink?) what is needed. I'm not sure whether or not one would need to use the chroot command to do this or not.

If I knew the exact setup I would then I could create a second script to restrict the above folders and create alternative folders for non-root users.
Back to top
View user's profile Send private message Visit poster's website 
musher0

Joined: 04 Jan 2009
Posts: 14521
Location: Gatineau (Qc), Canada

PostPosted: Sat 04 May 2019, 14:21    Post subject:  

What happened to chmod -R ?
_________________
musher0
~~~~~~~~~~
Je suis né pour aimer et non pas pour haïr. (Sophocle) /
I was born to love and not to hate. (Sophocles)
Back to top
View user's profile Send private message 
s243a

Joined: 02 Sep 2014
Posts: 2189

PostPosted: Sat 04 May 2019, 16:00    Post subject:  

musher0 wrote:
What happened to chmod -R ?


I suppose if things were really broken I might want to do that but it was only the directory permissions that were broken for me. That said even if I needed to also fix the files, I probably wouldn't use chmod -R because I might not want to do the same thing for each file.
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [5 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0376s ][ Queries: 11 (0.0089s) ][ GZIP on ]