Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pam_access: Support UID and GID in access.conf #186

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

blueskycs2c
Copy link

pam_access: Support UID and GID in access.conf fix #114.

eg:access.conf
-:ALL EXECPT (1000) 1002 :LOCAL

@blueskycs2c
Copy link
Author

@t8m please take a look ,and let me know if there is any problem.
Thanks!

@ldv-alt
Copy link
Member

ldv-alt commented Mar 17, 2020 via email

@blueskycs2c
Copy link
Author

Please make your patch clean from whitespace errors and re-push. Use "git diff --check 4b825dc642cb6eb9a060e54bf8d69288fbee4904" to check. Thanks.
@ldv-alt Thanks for your reply! I have revised it.

@ldv-alt
Copy link
Member

ldv-alt commented Mar 23, 2020

Could you document the proposed extension in the manual page, please?

@blueskycs2c blueskycs2c force-pushed the access-pr branch 2 times, most recently from 59e12e5 to b4cd702 Compare March 25, 2020 15:41
@blueskycs2c
Copy link
Author

Could you document the proposed extension in the manual page, please?

@ldv-alt Thanks for you reply.
I have add the information in access.conf.5.xml and re-push it.

Copy link
Member

@t8m t8m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the formatting as it is really sloppy. Try to follow the style of the surrounding code.

"user_match: tok=%s, item=%s", tok, item->user->pw_name);

memset(buf,0,BUFSIZ);
//tok is uid
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please no C++ style comments.

"user_match: tok=%s, item=%s", tok, string);
"user_match: tok=%s, item=%s", tok, item->user->pw_name);

memset(buf,0,BUFSIZ);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please spaces after commas

@@ -511,14 +511,26 @@ netgroup_match (pam_handle_t *pamh, const char *netgroup,
static int
user_match (pam_handle_t *pamh, char *tok, struct login_info *item)
{
char *string = item->user->pw_name;
char *string = NULL ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please no space before ;


memset(buf,0,BUFSIZ);
//tok is uid
if(strspn(tok,"0123456789") == strlen(tok)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please space after if and comma

sprintf(buf, "%d", item->user->pw_uid);
if(item->debug)
pam_syslog(pamh, LOG_DEBUG, "user_match: tok = %s, uid= %d", tok , item->user->pw_uid);
string = buf ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no space before ;

@@ -588,7 +601,16 @@ group_match (pam_handle_t *pamh, const char *tok, const char* usr,
memset(grptok, 0, BUFSIZ);
strncpy(grptok, tok + 1, strlen(tok) - 2);

if (pam_modutil_user_in_group_nam_nam(pamh, usr, grptok))
if(strspn(grptok, "0123456789") == strlen(grptok)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space after if

if(strspn(grptok, "0123456789") == strlen(grptok)) {
grpgid = atoi(grptok);

if(debug)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space after if


if(debug)
pam_syslog(pamh,LOG_DEBUG,"group_match:grpgid = %d,user= %s",grpgid,usr);
// tok is GID
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No C++ style comments

if(debug)
pam_syslog(pamh,LOG_DEBUG,"group_match:grpgid = %d,user= %s",grpgid,usr);
// tok is GID
if(pam_modutil_user_in_group_nam_gid(pamh,usr,grpgid))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space after if and after commas

grpgid = atoi(grptok);

if(debug)
pam_syslog(pamh,LOG_DEBUG,"group_match:grpgid = %d,user= %s",grpgid,usr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces after commas

@blueskycs2c
Copy link
Author

Please fix the formatting as it is really sloppy. Try to follow the style of the surrounding code.

@t8m Thanks for your reply! I have revise it.

Copy link
Member

@t8m t8m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more formatting nits.

@@ -179,6 +179,11 @@
</para>
<para>-:root:ALL</para>

<para>
User with uid <emphasis>1003</emphasis> and group with gid <emphasis>1000</emphasis> should be allowed to get access
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split this overly long line. Also should it be rather 'An user' and 'a group'?

if (item->debug)
pam_syslog(pamh, LOG_DEBUG, "user_match: tok=%s, uid=%d", tok, item->user->pw_uid);
string = buf;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop this empty line.

/* grptok is GID */
if (strspn(grptok, "0123456789") == strlen(grptok)) {
grpgid = atoi(grptok);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop this empty line.

pam_syslog(pamh,LOG_DEBUG,"group_match:grpgid=%d, user=%s", grpgid, usr);
if (pam_modutil_user_in_group_nam_gid(pamh, usr, grpgid))
return YES;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop this empty line.

grpgid = atoi(grptok);

if (debug)
pam_syslog(pamh,LOG_DEBUG,"group_match:grpgid=%d, user=%s", grpgid, usr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please spaces after commas, and after ':'.

@mluckam
Copy link

mluckam commented May 22, 2023

@t8m @blueskycs2c it appears that the review comments were addressed. Any reason this feature was not merged? Would be useful functionality. Please let me know if I can help.

@t8m
Copy link
Member

t8m commented Jul 25, 2023

This needs to be rebased to resolve the conflict. I would approve it then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pam_access: Support UID and GID in access.conf
4 participants