Operating System - HP-UX
1753787 Members
7840 Online
108799 Solutions
New Discussion юеВ

Re: To restrict a directory to a specific user

 

To restrict a directory to a specific user

Hi all.

I have a directory which all the users [diferents groups] have full access, but how can I restrict that directory to a specific user?
Do I have to modify the passwd file?

My OS is HPUX 3.11

Thanks in advanced.

[DASM]
8 REPLIES 8
Dennis Handly
Acclaimed Contributor

Re: To restrict a directory to a specific user

You can restrict it to a given user or group by making sure that user is the owner.
Steven E. Protter
Exalted Contributor

Re: To restrict a directory to a specific user

Shalom,

Lets say I have a directory called

/data

owned by an app user.
group is appuser

if all full access users have the group appuser and the permissions on the directory are at least group read the members of the appuser group will have access and users that are not members of the group will not.

chmod 750 /data

for example.

Basically, prevent users outside the group from access and configure those users you want to keep out not to have the group.

No change in /etc/passwd, some changes in /etc/group and permissions on the directory.

Hope this helps.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com

Re: To restrict a directory to a specific user

Hi.

I have 4 users:

user1 [group appuser1]
user2 [group appuser2]
user3 [group appuser3]
user4 [group appuser4]

The directory data has the following permissions:

drwxrwxrwx 4 user1 appuser2 8192 Nov 25 19:58 data

How can I restrict this directory to user4?
I can not change the group to the users.

Thanks in advanced.
Dennis Handly
Acclaimed Contributor

Re: To restrict a directory to a specific user

>drwxrwxrwx 4 user1 appuser2 data
>How can I restrict this directory to user4?

chown user4 data
chmod go-w data

If you don't want then to even see the files you can remove rx.
Dennis Handly
Acclaimed Contributor

Re: To restrict a directory to a specific user

Typo: If you don't want user1 ... user3 to even see the files you can remove rx.

Re: To restrict a directory to a specific user

Hi Dennis Handly.

The problem is everybody need to access this directory, except user4.

Thanks.
Dennis Handly
Acclaimed Contributor

Re: To restrict a directory to a specific user

>The problem is everybody need to access this directory, except user4.

(Then "restrict" was probably the wrong word, exclude would have been better.)

You could use ACLs to only allow user1 ... user3 or their groups. If there is more to "everybody", just add them one by one.
V. Nyga
Honored Contributor

Re: To restrict a directory to a specific user

Hi,

you can add user1 to user3 to a new group (additional to the existing one).
Then assign the dir to this new group, then exclude other users to access the dir.

chgrp data
chmod 770 data

If you want this rights also for subdir or files use the option -R.

HTH
V.
*** Say 'Thanks' with Kudos ***