users who have un-sanctioned(forbidden) files in their home directory.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting users who have un-sanctioned(forbidden) files in their home directory.
# 1  
Old 05-11-2011
users who have un-sanctioned(forbidden) files in their home directory.

Hello guys,

I have to create a sh script which return users who have un-sanctioned(forbidden) files in their home directory.

I tried to do:
Code:
#!/bin/sh -x
SHADOW_FILE="/etc/shadow"
PASSWORD_FILE="/etc/passwd"

for i in `grep -v '^+' $PASSWORD_FILE | cut -d: -f1,6`
do
  username=`echo $i|cut -d: -f1`
  home_dir=`echo $i|cut -d: -f6`  

.....
done

Above is just a part of script.
I don't know how to get files rights from each home directory. Any hint it will be great.
Thanks.

Last edited by Franklin52; 05-11-2011 at 02:09 PM.. Reason: Please use code tags, thank you
# 2  
Old 05-11-2011
Like this?

Code:
find . | xargs ls -ld | awk '{print $1 FS $9}'

Code:
[ahamed@ahamed study]$ find . | xargs ls -ld | awk '{print $1 FS $9}'
drwxr-xr-x. .
-rw-r--r--. ./a1
-rw-r--r--. ./a2
-rwxrwxr-x. ./a.out
-rwxr-xr-x. ./brun
-rw-r--r--. ./c

If Solaris, use /usr/xpg4/bin/awk

regards,
Ahamed
This User Gave Thanks to ahamed101 For This Post:
# 3  
Old 05-11-2011
Hi,

Yes, it is a solaris os but i need to display something like this:

User abcd has the following restricted files in home: a.file, b.file...etc (in /export/home i have many users)
Your script returns all files form all users? I don't understand very well the code. Could you give me more details or some links to some tutorials.

Thanks.
# 4  
Old 05-11-2011
By "restricted files", what do you mean?
BTW, my previous post was just to give you an idea.

regards,
Ahamed
# 5  
Old 05-11-2011
As i understand, restricted means that the user john from /export/home/john doesn't have access to this file(when i say access this means , doesn't have rights to execute, modify or read the file).
It is possible to be wrong related to the understanding of "restricted file". What do you think about...do you have other opinion about it?

regards,
catalin
# 6  
Old 05-11-2011
Quote:
Originally Posted by catalint
As i understand, restricted means that the user john from /export/home/john doesn't have access to this file(when i say access this means , doesn't have rights to execute, modify or read the file).
It is possible to be wrong related to the understanding of "restricted file". What do you think about...do you have other opinion about it?

regards,
catalin
If it's in a user's home directory, the user pretty much has permissions to do anything they want with it.

IIRC about the only thing a user can't do to finles and directories in a directory the user owns is delete a directory owned by another user that has the setgid-bit set on it.

What problem are you trying to solve?
# 7  
Old 05-12-2011
But if the file was copied in the home directory by a user or by another program and its rights are very restrictive.
As I read "each file belongs to a specific user and group. Access to the files is controlled by user, group, and what is called other. The term, other, is used to refer to someone who is not the user (owner) of the file, nor is the person a member of the group the file belongs to. When talking about setting permissions for "other" users to use, it is commonly referred to as setting the world execute, read, or write bit since anyone in the world will be able to perform the operation if the permission is set in the other category. "

let's say that the user john belong to temp group and
in /export/home/john we have a file script.sh
-rw------- 1 root root 14233 Apr 24 10:32 script.sh

=> user john has NO rights to read/execute/modify script.sh file because the owner of the file is root and group also is root.

That's what I mean and the question is: is this possible to find out these kind of files for each user from /export/home?

Thanks.

regards,
catalin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

How to set variable for users with no home directory?

Hi I need to set $HISTFILE for a user with no home directory. How to go about it because this user does not have a .profilefile. (5 Replies)
Discussion started by: fretagi
5 Replies

2. UNIX for Advanced & Expert Users

Permissions on a directory in /home for all users

Hi, I have created a shared directory on /home, where all users on a certain group have read, write and execute permissions. I did this using chmod -R g+rwx /home/shared/ The problem is, when a particular user creates a directory within /home/shared, other users are not able to write to... (8 Replies)
Discussion started by: lost.identity
8 Replies

3. Emergency UNIX and Linux Support

NIS created users without a home directory

Hi all, So I have created two Centos machines. One is configured as a NIS master and the second is a NIS cleint. The NIS configs are all working perfectly. I created a user nisuser on NIS Master and I can use it on the client. BUT it doesnt show a home directory . Ive been told there is... (9 Replies)
Discussion started by: Junaid Subhani
9 Replies

4. AIX

close ssh users to the home directory

Hello, I must close ssh users to the home directory. It means the users musn't see anything inside their home directory. For example after login to the os and type this command "cd .." or "cd /" it musn't work. How can I implement it? (Probably chroot or rootsh but how?) (1 Reply)
Discussion started by: jeszi
1 Replies

5. Solaris

what is the use of each login related files present in users home directory

# ls -l total 10 -rw-r--r-- 1 dummy2 other 140 Jun 19 21:37 local.cshrc -rw-r--r-- 1 dummy2 other 136 Jun 19 21:37 local.cshrc~ -rw-r--r-- 1 dummy2 other 157 Jun 19 21:37 local.login -rw-r--r-- 1 dummy2 other 178 Jun 19 21:37 local.profile... (6 Replies)
Discussion started by: chidori
6 Replies

6. Solaris

Common Home directory for different users??

Hi Guys, I have a problem with configuring a server. this is a solaris 10 with sparc platform. I have setup so that the server is Authenticating through NIS but I dont want the server to Mount the Home directories. The users need to logged in through the CDE/display. I have over 200 users... (2 Replies)
Discussion started by: Luky
2 Replies

7. Solaris

find home directory paths for all users

How to find al the user's home directories? (2 Replies)
Discussion started by: a2156z
2 Replies

8. UNIX for Dummies Questions & Answers

lost /home/directory for users

I'm using HPUX 11i. The other day a user logon to the workstation and was not able to find the /home/directory (tom is the directory) I login myself and it is the same thing. The home directory is on the server, so I was thinking of using sam to map it again. does anyone know how to do it... (5 Replies)
Discussion started by: blizzgamer
5 Replies

9. UNIX for Dummies Questions & Answers

Home Directory Jail for Users

Hi, I am looking for a shell script (or any other way), that puts a user in a home directory jail. So for example, I have a user named richard and I don't want him wandering outside /usr/users/richard. I don't want him to cd to anywhere including cd .. Somebody said you can do that with... (3 Replies)
Discussion started by: mz043
3 Replies

10. UNIX for Dummies Questions & Answers

Profiles for users without home directory

Hi I want to know which profile will be called when a user without home directory is created. When I created a user without home directory(by setting in /etc/default/useradd), the user is able to login directly into the main "/" folder but with only read permissions. Thanks naina (3 Replies)
Discussion started by: naina
3 Replies
Login or Register to Ask a Question