I have problem with OpenLdap and permission to file.
First - I set this in my slapd.conf:
overlay dynlist
dynlist-attrset labeledURIObject labeledURI
Second - I make cn=test,ou=Projects,dc=example,dc=com with:
dn: cn=test,ou=Projects,dc=example,dc=com
gidNumber: 6789
objectClass: posixGroup
objectClass: top
objectClass: labeledURIObject
labeledURI: ldap:///cn=testgroup,ou=Groups,dc=example,dc=com?memberUid?sub?
(objectClass=posixGroup)
memberUid: user1 (dynamic)
memberUid: user2 (dynamic)
in cn=testgroup,ou=Groups,dc=example,dc=com i have memberuid: user1 and memberUid: user2
Third - when i made getent group test I have:
test:*:6789:user1,user2
But when I try id user1 i didn't see this group :(
And next I set chmod 770 dir and chown root.test dir and try access to this dir.
But of course it is not possible because the user is not in this group (that said "id").
Does anyone know the solution?
Third - when i made getent group test I have:
test:*:6789:user1,user2
But when i try id user1 i didn't see this group :(
Unfortunately dynamic lists (dynlists) are ONE WAY groups (not TWO way). This means that reverse lookups won't work, which causes the very issue you are now facing. There is no way to make reverse posix group lookups work with dynlist.
HOWEVER, there is another module available somewhere on OpenLDAP's site I believe. It is called autogroup. This is a static-group maintainer module. This method of grouping does not involved dynamic data, rather it is REAL data that is automagically managed by the autogroup module. However, it is configured similar to a dynlist group as it uses the labeledURI attribute to allow a "stored procedure" so to speak.
I too was disappointed when I realized the shortcomings of dynlist, and I should point out that autogroup is still somewhat experimental. Test thoroughly and report any bugs to OpenLDAP.
I hope this helps...
Max
Groups are constructed here in this way without memberUid, but member:
dn: cn=mygroup,ou=groups,o=company
objectClass: posixGroup
objectClass: top
objectClass: groupOfNames
cn: mygroup
member: uid=user1,ou=users,o=company
displayName: mygroup
gidNumber: 1234
The schema type is also to be set to RFC2307bis (ldap_schema = rfc2307bis in sssd.conf).
For the 3rd issue, the problem is that id will use a ldap request with (member=uid=login,... ) while getent group will search for the group ( cn=groupname ). So the 2nd one trigger the overlay , while the first don't ( see the man page ). I also faced the issue, and found some links about it :
http://www.openldap.org/lists/openldap-software/200708/msg00250.html and http://www.openldap.org/lists/openldap-devel/200708/msg00127.html.
So far, I didn't found any good solution, maybe changing nss_ldap would work ( if you use it, which you didn't explained )
Related
Scenario 1:
I have 2 users, each has a different primary group.
For user1, the primary group is group1 with GID 501.
For user2, the primary group is group2 with GID 502.
I edited /etc/passwd so that user1 now has GID 600.
However, I forgot to create a new group with GID 600 (and I did not edit /etc/group either).
What's surprising me is that even though I never created a group with GID 600 (and thus there's no such group in /etc/group)- everything works as if such a group exists:
Examples:
1) After user1 creates a new file- test.txt, User2 can't r/w that file.
2) When running ls -l I can see that test.txt belongs to GID 600.
What am I missing? Why does it work even though there's inconsistency between /etc/passwd and /etc/group?
Scenario 2:
Say I have a group with GID 1000.
When running useradd -c "name" test2 -g 1000, and then groups test2, I can see that test2's primary group is 1000.
However, in /etc/group all I see is test_group:x:1000:, meaning test2 isn't a member of test_group.
Moreover, after running useradd -c "name" test3, I do have test3:x:8093: in /etc/group.
Can you explain why it's happening?
Thanks.
Non programming question, expect downvotes... you should ask on superuser or unix.se
That said, there is no mapping of UID numbers to GID numbers that require them to have the same values. Think about what happens when you add a few users, then create a group or two for them to share, then add a few more users. The "next available" GID/UID pair don't match in value, but that doesn't matter.
When you are looking at a user's primary group, they aren't listed in the groups file as being a member because their primary group info is in the passwd file.
Remember to find files/directories that have no owning user or group if you manually change a UID number or GID number, and fix as appropriate.
Also, when it comes to UID numbers and GID numbers there is 0 (root) and everything else - no special meaning to them. By consensus, "system user" type accounts are low, and most distributions start creating "normal" users with a UID/GID of 1000
I am trying to apply security in Kylo, such as the feed and category created by one user if it is not visible to other users.
Is it possible in Kylo HDP Sandbox?
If yes, what changes do I need to make?
Yes, you can do this via Kylo's entity-level access control mechanism. Below is an illustration to enable entity access for categories in Kylo sandbox.
Step 1: Enable entity access control
Update kylo-services/conf/application.properties
security.entity.access.controlled=true
security.auth.file.users=file:///opt/kylo/users.properties
security.auth.file.groups=file:///opt/kylo/groups.properties
Step 2: Define users
Create a file called users.properties, populate it and give proper permissions. The structure of each entry is username=password.
$ vi /opt/kylo/users.properties
#entries in file
dladmin=thinkbig
analyst=analyst
designer=designer
operator=operator
$ chown kylo:users /opt/kylo/users.properties
$ chmod 600 /opt/kylo/users.properties
Step 3: Define groups
Create a file called groups.properties, populate it and give proper permissions. The structure of each entry is user=group memberships.
$ vi /opt/kylo/groups.properties
#entries in file
dladmin=admin,user
analyst=analyst,user
designer=designer,user
operator=operations,user
$ chown kylo:users /opt/kylo/groups.properties
$ chmod 600 /opt/kylo/groups.properties
Step 4: Restart Kylo
$ /opt/kylo/stop-kylo-apps.sh
$ /opt/kylo/start-kylo-apps.sh
Step 5: Log in as dladmin user (password: thinkbig)
Create a category (say sample_category). Do not give any entity level permissions.
Step 6: Log in as operator user (password: operator)
Look at the list of categories. sample_category is not visible since no permissions were given by the dladmin user.
Step 7: Log back in as dladmin user and give permissions
Give Editor role to Operations group. The operator user is a member of Operations group.
Step 8: Log back in as operator user
Look at the list of categories. sample_category is now visible
I would like to get the security group of the user in a Maximo automation script so I can compare it. I need to know if the user in in MaxAdmin or UserUser group to execute the reste of my script. My scripts are in Python
how could I get that Info?
There are some implicit variables available to you in an automation script (check the IBM Automation Script guide), one of which is the current user's username. There is also the :&USERNAME& special bind variable that gets replaced with the current username. You can use one of those as part of the query to fetch a GroupUser MBO and then check the count of it afterward.
I'm going off of memory here so the exact names and syntax probably differ, but something like:
groupUserSet = MXServer.getMXServer().getMboSet("GROUPUSER", MXServer.getMXServer().getSystemUserInfo())
groupUserSet.setWhere("userid = :&USERNAME& and groupname in ('MAXADMIN', 'USERUSER')")
# Not really needed.
groupUserSet.reset()
if groupUserSet.count() > 0:
# The current user is in one of the relevant groups.
else:
# The current user is not in one of the relevant groups.
groupUserSet.close()
It's worth noting that the kinds of things tied to logic like this usually don't need an automation script. Usually conditional expressions, normal security permissions or reports can do what you need here instead. Even when an automation script like this is needed, you still should not do it based on group alone, but based on whether the user has a certain permission or not.
EDIT
To do this with permissions, you would add a new sigoption to the app with an id along the lines of "CANCOMPPERM" (with a more verbose description) and grant it to those two groups. Make sure everyone in those groups logs out at the same time (so nobody in those two groups are logged into the system at a given point) or else the permission cache will not update. Your code would then look something like this:
permissionsSet = MXServer.getMXServer().getMboSet("APPLICATIONAUTH", MXServer.getMXServer().getSystemUserInfo())
permissionsSet.setWhere("optionname = 'CANCOMPPERM' and groupname in (select groupname from groupuser where userid = :&USERNAME& )")
# Not really needed.
permissionsSet.reset()
if permissionsSet.count() > 0:
# The current user has the necessary permission.
else:
# The current user does not have the necessary permission.
permissionsSet.close()
I think there are even some helper methods in Maximo's code base that you can call to do the above for you and just return a true/false on if the permission is granted or not.
I have some questions about getent group.
Where does getent group A get the information on group A?
Does it only get it from /etc/group?
Is it possible that I can find a user (belonging to group A) by getent group A while I can not find the user from group A in /etc/group? If yes, how could this happen?
The third one is actually the problem I met.
Example:
1st. [root#*** test]# getent group A | grep A
2nd. [root#*** test]# cat $INSTALLROOT/etc/group | grep A
I can find a user a from the first command while I cannot find the user a from the second command.
Where does "getent group A" get the information on group A?
It is configured in /etc/nsswitch.conf. man getent tells this.
Does it only get from /etc/group?
It depends on your config files. On my machine it does not get this information only from /etc/group since it is configured in this way:
group: files ldap
is it possible that i can find a user (belong group A) by "getent group A" while can NOT find the user from group A in /etc/group?
Yes it is possible if there are at least two sources of data for groups.
By the way, take a look at how getent group work - run it under strace.
strace -s 256 -o getent.strace.txt -v getent group
And see what system calls it does. In my case it first reade from /etc/group and loads an ldap module and starts reading from socket
I know there's 0,1,5,6 and 7 for each category of user
e.g. 755, 644, 600 etc
how many combinations can we have?
also, there's this u+755... what is this about really?
There are 4 user-manipulable permissions locations (special permissions [setuid, setgid, sticky], user owner, group owner, other), and each can have one of 8 values.
8 ** 4 = 4096
The 3 numbers denote owner/group/world
Each of them has read/write/execute bits. You are setting these when it comes to the 3 numbers.
So, 000 becomes
owner group world
rwx rwx rwx
000 000 000
777 (which allows everyone to read, write and execute the file) becomes
owner group world
rwx rwx rwx
111 111 111
644 allows owner to read/write. Group and world to only read.
owner group world
rwx rwx rwx
110 100 100
And so on..
In total, there are 8 bits, which can be turned on/off, giving you 8^3. In addition, there are the special modes Sticky bit, SUID and SGID, and their various combinations, further giving you 8 possibilities.
the unix privileges on directories is categorised by [User][Group][Other] each of these have the options of [Read][Write][Execute]
so the form is [User]{RWX},[Group]{RWX},[Other]{RWX}
so the permissions are [U]RWX [G]RWX [O]RWX so if you are familiar with the binary representation of decimal numbers you can understand that
755 would be decoded to [U]111 [G]101 [O]101 so this means [U]RWX [G]R-X [O]R-X
600 would be decoded to [U]110 [G]000 [O]000 so this means [U]RW- [G]--- [O]---
644 would be decoded to [U]110 [G]100 [O]100 so this means [U]RW- [G]R-- [O]R--
and about the available combinations are 2^9= 512 available permissions
where 2 is the number of available choices (0,1) that could be placed in one of the 9 available places
[U]123 [G]456 [O]789 in the general form.
you can check this link for further details and tutorial.
Every file and directory has their certial set of permissions on User (who owns the files), Group (Group is to which that user belongs and all the users belongs to this group will fall in this category) and Others ( rest of the users and group present inside the system).
Now each of these categories (User/Group/Others) can have combination of Read, Write or Execute permissions.
Read - 4
Write -2
Execute - 1
So if a file has [read,write, execute] permissions for User and [read,execute] permission for Group and Others both then it is denoted as
chmod 755 filename
also, chmod u+rwx, g+rx, o+rx filename
Now if you just want to give USER (the first category) permissions on the file as [read,write] then it will be like :-
chmod u+rw filename.
I don't think the command (chmod u+755 filename) you have written is correct.