LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Shot myself in the foot (https://www.linuxquestions.org/questions/slackware-14/shot-myself-in-the-foot-694694/)

gmartin 01-03-2009 10:38 AM

Shot myself in the foot
 
OK, I made a mistake that is killing me. Long story, but I reset the permissions on /var/run to to be owned by root, group users with group having read/write as well. I then copied that down to the subfolders and stuff stopped working (most notably apache couldn't access mysql through the socket in /var/run/mysql).

Is there anyway to recover these permissions. Or in knowing how they should be set?

(FWIW, I have backups but not of the entire /var tree)
(FWIW2 - this is my home system and of not huge importance)


Thanks

repo 01-03-2009 10:47 AM

/var/run
drwxr-xr-x 35 0 0 4096 2009-01-03 16:49 run

The sub directorys have
drwxr-xr-x 2 0 0 4096 2008-07-29 16:33 sshd

Alien Bob 01-03-2009 10:48 AM

You may get help from the script Alan Hicks posted on a.o.l.s. some years ago. The script uses Slackware's "slackware/MANIFEST.bz2" file to generate a load of commands that reset the permissions back to the original state of every file/directory installed by Slackware.
You can capture these commandlines (they are written to the standard output of the script) and remove everything you don't need (only the commands that change permissions and owndership below /var are relevant to you).

You can find the posting of that script here: http://groups.google.nl/group/alt.os...1872abfdf2c110

Eric

GazL 01-03-2009 10:53 AM

These are mine if they help

directories:
Code:

root@jupiter:~# find /var/run -type d -exec ls -ld {} \;
drwxr-xr-x 14 root root 4096 2009-01-03 13:27 /var/run
drwxr-xr-x 3 root lp 48 2008-12-05 13:52 /var/run/cups
dr-x--x--x 2 lp sys 1 2008-12-05 13:52 /var/run/cups/certs
drwxr-xr-x 2 root root 16 2009-01-03 13:27 /var/run/dbus
drwxr-xr-x 4 haldaemon haldaemon 16 2008-12-08 01:14 /var/run/hald
drwxr-xr-x 2 root root 1 2008-12-08 01:14 /var/run/hald/hald-local
drwxr-xr-x 2 root root 1 2008-12-08 01:14 /var/run/hald/hald-runner
drwxr-xr-x 2 root root 1 2008-10-22 23:55 /var/run/httpd
drwxr-xr-x 2 root root 1 2008-02-27 03:40 /var/run/iptraf
drwxr-xr-x 2 mpdserv mpdserv 8 2009-01-03 13:27 /var/run/mpd
drwxr-xr-x 2 mysql mysql 1 2008-10-05 06:29 /var/run/mysql
drwxr-xr-x 2 root root 1 2008-09-17 07:35 /var/run/named
drwxr-xr-x 2 root root 1 2008-11-21 07:09 /var/run/nscd
drwxr-xr-x 2 root root 1 2008-11-14 23:45 /var/run/proftpd
drwxr-xr-x 2 root root 1 2006-09-12 08:33 /var/run/stunnel
drwx------ 2 root root 1 2008-12-12 16:04 /var/run/sudo

files:
Code:

root@jupiter:~# find /var/run -type f -exec ls -ld {} \;
-rw-r--r-- 1 root root 5 2009-01-03 13:27 /var/run/acpid.pid
-rw-r--r-- 1 root root 5 2009-01-03 13:27 /var/run/atd.pid
-rw-r--r-- 1 root root 5 2009-01-03 13:27 /var/run/dbus/dbus.pid
-rw-r--r-- 1 root root 5 2009-01-03 13:27 /var/run/gpm.pid
-rw-r--r-- 1 root root 5 2009-01-03 13:27 /var/run/klogd.pid
-rw-r--r-- 1 mpdserv mpdserv 5 2009-01-03 13:27 /var/run/mpd/mpd.pid
-rw-r--r-- 1 root root 4 2009-01-03 13:27 /var/run/ntpd.pid
-rw-r--r-- 1 root root 5 2009-01-03 13:27 /var/run/syslogd.pid
-rw-rw-r-- 1 root utmp 4608 2009-01-03 13:33 /var/run/utmp


BCarey 01-03-2009 11:20 AM

Quote:

Originally Posted by gmartin (Post 3395751)
(most notably apache couldn't access mysql through the socket in /var/run/mysql).

/var/run/mysql should be owned by mysql:mysql. Apache doesn't access this directly, but communicates with the mysqld (daemon) process which does.

Brian

gmartin 01-03-2009 12:06 PM

Eric, I'm trying a hybrid approach. I'm reviewing the contents of MANIFEST And setting the perms by hand. I can always go back and cleanup MANIFEST and run the script. Thanks

Brian, when I set /var/run/mysql to mysql:mysql I get this error from a web app
Code:

Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (13)
Granting apache access to the directory resolves the problem. Any ideas?

BCarey 01-03-2009 12:25 PM

what does "ls -l /var/run/mysql" show?

Brian

gmartin 01-03-2009 02:23 PM

Quote:

Originally Posted by BCarey (Post 3395848)
what does "ls -l /var/run/mysql" show?

Brian

Code:

root@USlack2:/etc/cron.weekly# ls -l /var/run/mysql
total 4
-rw-rw-r-- 1 mysql mysql 5 2009-01-01 01:24 mysql.pid
srwxrwxr-x 1 mysql mysql 0 2009-01-01 01:24 mysql.sock=

If I add the apache user to the mysql group, everything works.
Note: this is a php app if it matters.

BCarey 01-03-2009 02:53 PM

Is that = sign at the end of mysql.sock a typo?

"chmod o+w /var/run/mysql.sock" should take care of it.

Brian

haertig 01-03-2009 03:12 PM

Following GazL's lead, here are mine (Slackware 12.1, basic install):
Code:

root@FamilyRoom:/# find /var/run -type d -exec ls -ld {} \;
drwxr-xr-x 13 root root 1024 2009-01-01 09:02 /var/run
drwxr-xr-x 2 mysql mysql 1024 2008-04-28 15:54 /var/run/mysql
drwxr-xr-x 3 root lp 1024 2009-01-01 09:02 /var/run/cups
dr-x--x--x 2 lp sys 1024 2009-01-01 09:02 /var/run/cups/certs
drwxr-xr-x 2 root root 1024 2006-09-12 01:33 /var/run/stunnel
drwxr-xr-x 2 root root 1024 2008-04-19 23:41 /var/run/nscd
drwxr-xr-x 2 root root 1024 2009-01-01 09:02 /var/run/httpd
drwx------ 2 root root 1024 2008-10-02 15:48 /var/run/sudo
drwxr-xr-x 2 root root 1024 2008-02-26 20:40 /var/run/iptraf
drwxr-xr-x 2 root root 1024 2007-12-10 12:04 /var/run/proftpd
drwxr-xr-x 2 root root 1024 2009-01-01 09:02 /var/run/dbus
drwxr-xr-x 4 haldaemon haldaemon 1024 2008-04-01 16:06 /var/run/hald
drwxr-xr-x 2 root root 1024 2008-04-01 16:06 /var/run/hald/hald-runner
drwxr-xr-x 2 root root 1024 2008-04-01 16:06 /var/run/hald/hald-local
drwxr-xr-x 2 root root 1024 2008-04-13 16:07 /var/run/named
root@FamilyRoom:/# find /var/run -type f -exec ls -ld {} \;
-rw-r--r-- 1 root root 5 2009-01-01 09:02 /var/run/gpm.pid
-rw-r--r-- 1 root root 5 2009-01-01 09:02 /var/run/sshd.pid
-r--r----- 1 root sys 32 2009-01-01 09:02 /var/run/cups/certs/0
-rw-r--r-- 1 root root 5 2009-01-01 09:02 /var/run/hald.pid
-rw-r--r-- 1 root root 5 2009-01-01 09:02 /var/run/atd.pid
-rw-r--r-- 1 root root 5 2009-01-01 09:02 /var/run/syslogd.pid
-rw-r--r-- 1 root root 5 2009-01-01 09:02 /var/run/httpd/httpd.pid
-rw-r--r-- 1 root root 5 2009-01-01 09:02 /var/run/inetd.pid
-rw-r--r-- 1 root root 5 2009-01-01 09:02 /var/run/klogd.pid
-rw-r--r-- 1 root root 5 2009-01-01 09:02 /var/run/dbus/dbus.pid
-rw-rw-r-- 1 root utmp 4992 2009-01-03 12:06 /var/run/utmp
root@FamilyRoom:/#


Alien Bob 01-03-2009 04:33 PM

Quote:

Originally Posted by BCarey (Post 3395974)
Is that = sign at the end of mysql.sock a typo?

The mysql.sock is a socket file, the '=' is how that fact is shown to the user, like an executable file is distinguished by the '*' at the end.

Eric

BCarey 01-03-2009 04:42 PM

Quote:

Originally Posted by Alien Bob (Post 3396079)
The mysql.sock is a socket file, the '=' is how that fact is shown to the user, like an executable file is distinguished by the '*' at the end.

Eric

Interesting. Why wouldn't it show up when I do ls -l?

Brian

gmartin 01-03-2009 05:45 PM

Solved
 
Quote:

Originally Posted by BCarey (Post 3395974)
Is that = sign at the end of mysql.sock a typo?

"chmod o+w /var/run/mysql.sock" should take care of it.

Brian

OK, indeed it did. Question is, what did it do?

Before:
Code:

root@USlack2:/var/run/mysql# ls -l
-rw-rw-r-- 1 mysql mysql 5 2009-01-01 01:24 mysql.pid
srwxrwxr-x 1 mysql mysql 0 2009-01-01 01:24 mysql.sock=

root@USlack2:/var/run/mysql# chmod o+w mysql.sock

After:
Code:

root@USlack2:/var/run/mysql# ls -l
total 4
-rw-rw-r-- 1 mysql mysql 5 2009-01-01 01:24 mysql.pid
srwxrwxrwx 1 mysql mysql 0 2009-01-01 01:24 mysql.sock=

Looking at the results it appears you gave world(others) write rights. I was confused by the 'o' As I was thinking owner. 'man chmod' set me straight.

One other thing. the "=" is not a typo. It shows in the console like that. What does that mean?

gmartin 01-03-2009 05:47 PM

Quote:

Originally Posted by haertig (Post 3395995)
Following GazL's lead, here are mine (Slackware 12.1, basic install):

Thanks. The more info the better.

gmartin 01-03-2009 05:51 PM

I need to find a good tutorial on unix/linux rights. I know the basics, ok. But the sticky bit, uid & gid still trip me up. For instance, the "s" at the beginning of this line:
Code:

srwxrwxrwx 1 mysql mysql 0 2009-01-01 01:24 mysql.sock=
I assume that's sticky but I'm not sure what that means.

GazL 01-04-2009 05:44 AM

Quote:

Originally Posted by gmartin (Post 3396147)
I need to find a good tutorial on unix/linux rights. I know the basics, ok. But the sticky bit, uid & gid still trip me up. For instance, the "s" at the beginning of this line:
Code:

srwxrwxrwx 1 mysql mysql 0 2009-01-01 01:24 mysql.sock=
I assume that's sticky but I'm not sure what that means.

Nope. The first character denotes what type of file it is,

d = directory
- = regular file
l = symbolic link
b = block device
s = socket
... and some other less common ones.

The Sticky bit is actually depicted by a 't' in the last column, e.g. drwxrwxrwt.

Over the years, the purpose of the sticky bit has evolved. The wikipedia article linked above has more details.

If you want a starting place to learn a little more, the following is quite often recommended:
http://rute.2038bug.com/index.html.gz

Penthux 01-04-2009 06:06 AM

Quote:

Originally Posted by gmartin (Post 3396147)
I need to find a good tutorial on unix/linux rights. I know the basics, ok. But the sticky bit, uid & gid still trip me up. For instance, the "s" at the beginning of this line:
Code:

srwxrwxrwx 1 mysql mysql 0 2009-01-01 01:24 mysql.sock=
I assume that's sticky but I'm not sure what that means.

The "s" is a world-accessible socket. Meaning, the socket is accessible to anyone logged in on the machine.

gmartin 01-04-2009 10:05 AM

Thanks everyone. System is working fine. I set the permissions by hand. Hopefully I'll be more careful in the future. I also learned a few things so all in all, it was a good day.

Happy New Year

bgeddy 01-04-2009 11:21 AM

Quote:

Quote:
Originally Posted by Alien Bob View Post
The mysql.sock is a socket file, the '=' is how that fact is shown to the user, like an executable file is distinguished by the '*' at the end.

Eric
Quote:

Interesting. Why wouldn't it show up when I do ls -l?
@BCarey: Are you running the command from an X terminal (Konsole or Terminal or such like) ? In runlevel 3 "/etc/profile" sources all the "*.sh" files in "/etc/profile.d". One of these "/etc/profile.d/coreutils-dircolors.sh" sets an alias for the ls command to include the -F option amongst others which appends a classifier to filenames and directories.

This alias is not set when using an X terminal. To simulate this just try "ls -lF" from the terminal.

If you are seeing this odd behaviour from the console then check you have an "/etc/profile" and an "/etc/profile.d/coreutils-dircolors.sh" file that is marked as being executable.

A standard full install should set these up to assign the dircolors and aliases.


All times are GMT -5. The time now is 04:08 AM.