Re-apply the file permission


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Re-apply the file permission
# 8  
Old 08-17-2010
Quote:
To fix it I need to read the file's existing permission and re-apply the same permission to the file.
I'm completely lost on the point of this exercise and how it could fix anything. It could just be the ambiguous use of the phrase "the file". In your example one is a "link" and another is "special file" but none are "files".

Are there two computers involved here?

Can you give before and after examples and define the rules clearly.
# 9  
Old 10-04-2010
Data Got a temp fix to su -

Hi methyl,
I had problem while login in with any user add to the sys group. So I tried with the truss and got errors like below for truss of su - command. I looked in to the permission of the files and compared them with the other working server. It was correct, even then I reapplied the same permission then ran the truss for the su - command an found the error for /dev/null disappeared. So I wanted to do that for every single file that appeared in the truss output. Then found that execute permission for the group was missing for the mount points like /dev, /devices, /etc, /opt. This was that preventing su - to any user with sys in secondary group.

Code:
19964/1:        52.4639 stat64("/dev/null", 0xFFBFF9D0)                 Err#13 EACCES

I used the code below and found several files were having permission 0745. And I changed them all to 755. Re-applying was insanity, so droped the idea and happened to find the real problem which prevented the su -

Code:
 
#!/bin/bash
find /devices > /tmp/filelist
exec 3< /tmp/filelist
 while read i <&3
 do
  perm=`ls -ld $i | cut -c2-10`
  case ${perm} in
   rwxrwxrwx) j=0777;;
   rwxr-xr-x) j=0755;;
   r-xr-xr-x) j=0555;;
   rw-rw-rw-) j=0666;;
   rw-rw----) j=0660;;
   rw-r--r--) j=0644;;
   rw-r-----) j=0640;;
   rw-------) j=0600;;
   r--r--r--) j=0444;;
   *) echo "NewPermission: $perm"&&amp;exit;;
  esac
  #echo "chmod $j $i";chmod $j $i
 done

After fixing this I got so many file permission error in /var/adm/messages. I tried and fixed few of them but its never ending. This server is running for more than 700days, Now I have to reboot this server for a hardware maintenance and I'm scared that this server will have issue during the reboot.

So I want to do a comparison of all the files permission with another identical working server and change the different ones. I found a solaris audit tool bart to take snapshot of files permission with MD5, but this tool is not available in this server. So is there a work around to do this or any suggestions?
# 10  
Old 10-08-2010
Fixed

Permission on the /usr, /, /usr, /usr/bin, /dev, /devices was not correct.
Once that was fixed su - was working for users with sys as secondary group.

There was no significant problem with server reboot.
# 11  
Old 10-08-2010
Thank you for replying with the resolution of this problem.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash to select text and apply it to a selected file in bash

In the bash below I am asking the user for a panel and reading that into bed. Then asking the user for a file and reading that into file1.Is the grep in bold the correct way to apply the selected panel to the file? I am getting a syntax error. Thank you :) ... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. Shell Programming and Scripting

Apply md5 hash to a field in csv file

I have a .csv file and I want to md5 hash the second column for each row in the file. File is something like data1,foobar1,123,345 data2,foobar2,456,9393 data3,foobar3,1002,10109 Output would be like data1,6c81243028f8e455fa617dd5f0232ce1,123,345... (3 Replies)
Discussion started by: jjwags
3 Replies

3. Homework & Coursework Questions

Finding the directories with same permission and then apply some default UNIX commands

Write a Unix shell script named 'mode' that accepts two or more arguments, a file mode, a command and an optional list of parameters and performs the given command with the optional parameters on all files with that given mode. For example, mode 644 ls -l should perform the command ls -l on all... (5 Replies)
Discussion started by: femchi
5 Replies

4. Shell Programming and Scripting

Finding the directories with same permission and then apply some default UNIX commands

HI there. My teacher asked us to write a code for this question Write a Unix shell script named 'mode' that accepts two or more arguments, a file mode, a command and an optional list of parameters and performs the given command with the optional parameters on all files with that given mode. ... (1 Reply)
Discussion started by: femchi
1 Replies

5. Shell Programming and Scripting

Apply file permission

Hi All, I would like to read the permission from a file and wanted to apply the same permission to another file. say for example, f1 755 first...i have to read the permission type (which is differ for each file) and need to apply the same for f2 a1 666 i have to get this... (5 Replies)
Discussion started by: karthi_mrkg
5 Replies

6. Shell Programming and Scripting

Apply condition on fixed width file and filter records

Dear members.. I have a fixed width file. Requirement is as below:- 1. Scan each record from this fixed width file 2. Check for value under field no "6" equals to "ABC". If yes, then filter this record into the output file Please suggest a unix command to achieve this, my guess awk might... (6 Replies)
Discussion started by: sureshg_sampat
6 Replies

7. UNIX for Dummies Questions & Answers

Do UNIX Permission apply to sub directories?

Hi Guys, Can you tell me if unix permissions apply to sub dirs? Dir is /home/ops/batch/files/all /home is rwxrwxrwx ops is rwxrwxrwx batch is rwxr-wr-w files is rwxrwxrwx all is rwxrwxrwx Having problems writing to all (does the userid nee to be the batch owner... (1 Reply)
Discussion started by: Grueben
1 Replies

8. Shell Programming and Scripting

Apply Password to already Written XLS File.

I need to apply password protection to a xls file.I had looked at SpreadSheet::WriteExcel but problem being i dont want to write the contents of file again as the formatting the file would be a pain. Is there way in which i write a entire file in one go , something like this ... (0 Replies)
Discussion started by: dinjo_jo
0 Replies

9. Cybersecurity

file permission/acl: 2 users with write access on 1 file...

Hello, i need some help/advice on how to solve a particular problem. these are the users: |name | group | ---------- --------------- |boss | department1 | |assistant | department1 | |employee | department1 | |spy | department2 | this is the... (0 Replies)
Discussion started by: elzalem
0 Replies

10. Programming

Apply patch for make file.

I just downloaded a updating make file to build Ethereal to .dll file, but I don't know how to update the old make file with this new one. Please help.. thnx a lot. (1 Reply)
Discussion started by: blueblood
1 Replies
Login or Register to Ask a Question