I'm trying to sudo chown -R vagrant:vagrant .ssh. From this answer, I was told to make sure the group exists, so I have. My output from dscl . list /Groups PrimaryGroupID lists vagrant as one of the groups, so why can't I chown?
I found that I wasn't able to use chown or chgrp, to change the group, until I filled out the following fields for the group using dscl:
AppleMetaNodeLocation:
GeneratedUID:
GroupMembership:
Password:
PrimaryGroupID:
RealName:
RecordName:
RecordType: dsRecTypeStandard:Groups
These appear to be the minimum required keys to fill out, before one can use the group with chown or chgrp.
I just looked up the record of the group that currently owned the file with dscl ("wheel"), and filled in what was missing for the desired group (Password, RealName, PrimaryGroupID) until chown allowed me to change the file's group to that group.
Unfortunately, there is one enigmatic record (GroupMembers, not GroupMembership which lists the members of the group) of the wheels record that I can't figure out how to generate or what it means, but chown let me change the group without having this field filled out.
Related
This question is related to Drupal 8 Group module, https://www.drupal.org/project/group
I am stuck and need help with how to programmatically add a user to a group with a particular role. I am trying to assign a user to a group and role via a feed import but unable to figure out how.
To elaborate, let's say we have two groups DEV and QA. DEV is of group type A and QA is of group type B. Both groups type A & B have roles X, Y and Z (group roles). Now, I have a user $account and I want it to get added to say group QA with role Y. Can someone help and state a way I can achieve this programmatically? Code examples/snippets will be extra helpful.
Some OLD code here that may help. Had to dig it out of git, deleted a couple of years ago as no longer needed by the project. May be deprecated!
You are loading up the group and using the $group->addMember() function. I have just added the member but you can add a second param that is an associative array that can indicate roles to add to.
$new_user = \Drupal\user\Entity\User::load($some_user_id);
// Get the group entity.
$gid = $form_state->getValue('gid');
$group = \Drupal::entityTypeManager()
->getStorage('group')
->load($gid);
// Add user as a member of the group.
$group->addMember($new_user);
// Set the owner of the group to be the user.
$group->set('uid', $new_user_id);
// Save changes to group. Anything below here should only be changes to
// Group Content.
$group->save();
$tags = $group->getCacheTagsToInvalidate();
Cache::invalidateTags($tags);
From Oozie (4.2.0, from hdp2.6) I want to be able to get the list of jobs belonging to a certain group:
oozie jobs -filter group=export
But this filter never matches.
I set up the job with a few variables (while experimenting):
variable oozie.job.acl
variable group.name
hadoop property oozie.job.acl
I can see (oozie jobs) the group name in the column Group (the one I gave for oozie.job.acl) but I cannot seem to use it in a filter.
Is there a trick I am missing or is it just not possible?
Normally as 'ls -al', the files always show like:
-rw-r--r-- 1 owner_name group_name size time file_name
But some of my files show:
-rw-r--r-- 1 owner_name 'number' size time file_name
And the 'number' does not exist in /etc/group
What does the 'number' mean? and how to fix it?
Many thanks!
The number is the group ID (gid). Groups and Users in a *nix system are numerical IDs (uid and gid). In a file system, the owning user and group will only ever be stored by its ID.
To display this, the user database is queried. With a modern *nix system, this could be anything, e.g. an LDAP directory, but the classic format is using the files /etc/passwd and /etc/group. If you see an ID instead of a name, it means your system couldn't find the entry in the user/group database. With a remote LDAP directory, this happens e.g. when the network is down. If you just use a traditional /etc/group file, this only happens when there is no entry.
Either the group was deleted or somebody changed the group of the file using a (non-existing) ID instead of a name or the file was copied from another system having this group and preserving the IDs while copying.
How to fix it depends on what you want. You can just chgrp the file to an existing group. Or you can create a group with this ID.
The numbers will be the group id's as opposed to the group name. To display group id's without group names, you can use ls -aln.
If a number shows amongst the names this is normally an issue with group name resolution i.e. if a group of files have been downloaded from an outside source and the group id's/names are "foreign" and therefore not understood by the local system.
Suppose we have some 400 jobs in different boxes then I want to put on hold the daily running jobs at 9-10 pm pm only?
Do you use WCC or command line?
In WCC you can just use a comma-separated list of jobs to see only the jobs you want. You can filter by status and select the jobs you want to take action on, then select 'change status' to do a sendevent but check off the 'future' box. Set it up so you send an 'on-hold' event at 9pm and again for an 'off-hold' at 10pm.
If you use command line you'll want to do something like below. Do all of your boxes have some naming conventions in common? If so you can run the command only once using the string that returns your boxes. In the AutoSys instance I work in we use a prefix structure...
To get the list of running jobs:
autorep -J prefix% | [find for windows or egrep for unix] " RU "
... Where you need the spaces between the double quotes and the two-letter status otherwise it would return lines where the item name contains those two characters.
To do a future sendevent use the usual sendevent syntax and just append the switches to indicate the time you want the action taken.
Will this accomplish what you're looking to do? If not please let us know if you're using windows or Unix as well as any additional information that can help us understand the specifics of your scenario.
I am trying to remove all users from a group using the Plone.Api method (within Plone4).
So I wrote this code:
users = api.user.get_users(groupname="The Test Group")
for user in users:
api.group.remove_user(groupname="The Test Group", username=user.id)
But the api.group.remove_user call does not seem to function. What is the proper way to remove users from a group within plone?
I paused this within my ipdb
This are the results from my calls:
ipdb> api.group.get(groupname=group_name)
<GroupData at /Plone/portal_groupdata/groupname:61fbc50d623142d7887384d70f25358b used for /Plone/acl_users/source_groups>
So far so good, I store this in a variable so I can try this again later (for the group argument).
ipdb> grp = api.group.get(groupname=group_name)
ipdb> api.user.get_users(groupname=group_name)
[<MemberData at /Plone/portal_memberdata/stolas#domain.org used for /Plone/acl_users>]
I notice I get my user from the group. Thus I am really in this group.
ipdb> user.id
'stolas#domain.org'
ipdb> api.group.remove_user(group=grp, username=user.id)
I try the remove call again, and check if my member is still within the group.
ipdb> api.user.get_users(groupname=group_name)
[<MemberData at /Plone/portal_memberdata/stolas#domain.org used for /Plone/acl_users>]
I still am..
Should I reindex security or something like that?
ps.
I also gave with api.env.adopt_roles(['Manager']) a try and the getToolByName(getSite(), 'portal_groups')
method portal_groups.removePrincipalFromGroup everthing rendered to a false.
plone.api uses the group tool to remove group memberships:
portal_groups = portal.get_tool('portal_groups')
portal_groups.removePrincipalFromGroup(user_id, group_id)
I guess your api.user.get_users(groupname="The Test Group") call returns an empty set.
Since you should pass the group name (group ID). Now you pass the group title.
The api.group.remove_user would also accept a group object instead of the group name.
Arguments ``groupname`` and ``group`` are mutually exclusive. You can
either set one or the other, but not both.
As I could not delete it as a user I thought of the following:
with api.env.adopt_roles(['Manager']):
api.user.delete(user=self.context)
parent = self.context.getParentNode()
parent.manage_delObjects([self.context.getId()])
As the user delete might fail I deleted the object as a Manager. This seemd to work without a Hitch.