Sponsored Content
Top Forums Shell Programming and Scripting users and groups /etc/group parsing Post 302522746 by catalint on Monday 16th of May 2011 01:03:56 PM
Old 05-16-2011
Hi guys,

This is what have I done:

Code:
#!/bin/bash

user_belongs()
{
if `groups $var1 | /usr/xpg4/bin/grep -q $var2`
then
return 0 else
return 1
fi

}



home_dir="/export/home/catalin"
username="catalin"
strOwner="owner"
strUser="user"
strGroup="group"
strOther="other"
strNoRights="---"

for i in $(ls -F $home_dir)
do
   #echo $i
   user_rights=`getfacl $i | grep $strUser | cut -d: -f3`
   group_rights=`getfacl $i | grep $strGroup | cut -d: -f4`
   other_rights=`getfacl $i | grep $strOther | cut -d: -f2`
   owner_file=`getfacl $i | grep $strOwner | cut -d: -f2`
   group_file=`getfacl $i | grep $strGroup | cut -d: -f2`
   other_file="other"

#echo "$owner_file"
  
if [ " $username" != "$owner_file" ]; 
then

             echo "Username $username is not the owner of the file $i"

             if user_belongs $username $group_file
             then
                 echo "Username $username belongs to $group_file group   
                 if [" $group_rights" = "$strNoRights"] 
                 then
                     if user_belongs $username $other_file
                     then
                         echo "Username $username belongs to $other_file group   
                         if [" $other_rights" = "$strNoRights"] 
                         then
                            
                            REASON="Forbidden file $i in the home directory of the user $username found."
                          
                            echo "Username $username from group other has no rights to access file $i" 
                         fi

                     fi

                 fi

             fi 
else 

             
              REASON="Forbidden file $i in the home directory of the user $username found."
             

fi

        
done

what do you think about? So..any ideas are welcome.

Regards,
Catalin
 

9 More Discussions You Might Find Interesting

1. Cybersecurity

Users and groups

Hi, Is it possible that one user belongs to many groups, or the relation of user/group is 1/1?. Thanks Ramón (2 Replies)
Discussion started by: rsanz
2 Replies

2. Linux

listing users and groups

RH 7.2 I'm trying to list the users & groups on my machine. I found the lsuser & lsgroup commands but no associated man pages. I typed: lsuser I get --> Valid options are: -a So I typed: lsuser -a I get --> Valid options are: groups, home So I typed: lsuser -a groups I get -->... (2 Replies)
Discussion started by: jalburger
2 Replies

3. UNIX for Dummies Questions & Answers

usermod -G and Group id login replacing existing groups

Hi all usermod -G Group_id login it is replacing the existiong Secoundry groups and is adding the only group speced in usermod command how can we retain the existing secoundry groups and add a user to a new group (6 Replies)
Discussion started by: pbsrinivas
6 Replies

4. UNIX for Dummies Questions & Answers

users and groups

hi eveyone i've recently requested my unix admin to create a userid for 2 groups. He created the id and i can see it by grep "id" /etc/group. But when i login with that id into unix and try to cd that group it says permission denied. something like cd /groupname -- permission denied Can my admin... (1 Reply)
Discussion started by: sammet
1 Replies

5. Solaris

Removing users from groups

How do I remove a user from a group? I'm using the usermod command but its not working. I have a user "abc" who is a member of the groups root and other. I'm trying to remove him from the group "other" (using CLI) which is his secondary group but it's not working. How do I do this? Is there any... (11 Replies)
Discussion started by: the_red_dove
11 Replies

6. UNIX for Dummies Questions & Answers

Group inside other groups

Hi How can I add a group1, group2 and group3 inside another global group called systemgroup? I have differents users in group1,2,3n and I create a sysgroup, now I want to add theses groups into the global.. is it possible? NOTE: Debian OS running. thanks (1 Reply)
Discussion started by: iga3725
1 Replies

7. UNIX for Dummies Questions & Answers

List users and groups

Hi I am new to unix so hopefully someone can help. I need to list all the users I have in my unix enviroment (AIX) and the groups (primary and secondary) they belong to. Can anyone help? Many thanks in advance (2 Replies)
Discussion started by: m3y
2 Replies

8. UNIX for Dummies Questions & Answers

Users in multiple groups?

Happy Thanksgiving Everyone!! I have a question about adding users to multiple groups. Thanks in advance Using Red Hat and here are the issues: Example: Users: Bob Mark Groups: SystemsAnalysts BusinessAnalysts If I am adding a user Bob to both groups (SystemsAnalysts and... (2 Replies)
Discussion started by: hansokl
2 Replies

9. UNIX for Advanced & Expert Users

Creating groups and users

Hi Could anyone please suggest how we can check in Linux if a user or a group name is already existing? In case of a user the command should also be able to specify the user with a given directory and shell. We can of course check this using a grep command but since that is just a pattern match,... (12 Replies)
Discussion started by: Dorothy
12 Replies
lvmpvg(4)						     Kernel Interfaces Manual							 lvmpvg(4)

NAME
lvmpvg - LVM physical volume group information file SYNOPSIS
DESCRIPTION
is an ASCII file that stores the volume-group information for all of the physical volume groups in the system. The information is stored in a hierarchical format. First, it starts with a volume group under which multiple physical volume groups can exist. Under each physical volume group, a list of physical volumes can be specified. There must be at least one physical volume group in each volume group that appears in this file. The physical-volume-group name must be unique within the corresponding volume group, although it is permissible to use a common physical volume group name across different volume groups. There can be as many volume groups in this file as there are in the system. Instead of using the and commands, the administrator can edit this file to create and extend physical volume groups. However, care must be taken to ensure that all physical volumes to be included in the file have already been defined in their respective volume groups by previ- ous use of or The file format has the following structure. and are keywords that introduce the names of the volume group and physical volume group, respectively. pv_path ... pv_path ... pv_path ... The variables are defined as follows: pv_path The block device path name of a physical volume within the volume group. pvg_name The name of the physical volume group. It must be unique within the volume group. vg_name The path name of the volume group. EXAMPLES
The following example shows an file containing two volume groups: the first containing two physical volume groups, each with two physical volumes defined in it; the second containing three physical volume groups, each with one physical volume defined in it. SEE ALSO
vgcreate(1M), vgextend(1M), vgreduce(1M), vgremove(1M), intro(7), lvm(7). lvmpvg(4)
All times are GMT -4. The time now is 07:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy