Skip to content

Commit

Permalink
Add 'sp_loginclass' to retrieve the user's login class
Browse files Browse the repository at this point in the history
  • Loading branch information
jasperla committed Oct 30, 2014
1 parent c5bec01 commit bf04f51
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions README
Expand Up @@ -56,6 +56,7 @@ Shadow::Passwd::Entry (Struct::PasswdEntry)
considered inactive and disabled.
sp_expire - days since Jan 1, 1970 when account will be
disabled
sp_loginclass - pointer to null-terminated user login class.


5. Description
Expand Down
4 changes: 3 additions & 1 deletion pwd/shadow.c
Expand Up @@ -66,6 +66,7 @@ static VALUE convert_pw_struct( struct passwd *entry )
INT2FIX(difftime(entry->pw_change, 0) / (24*60*60)), /* pw_change */
INT2FIX(difftime(entry->pw_expire, 0) / (24*60*60)), /* sp_expire */
Qnil, /* sp_flag */
rb_tainted_str_new2(entry->pw_class), /* sp_loginclass, user access class */
NULL);
}

Expand Down Expand Up @@ -107,7 +108,8 @@ Init_shadow()
"sp_namp","sp_pwdp","sp_lstchg",
"sp_min","sp_max","sp_warn",
"sp_inact","pw_change",
"sp_expire","sp_flag", NULL);
"sp_expire","sp_flag",
"sp_loginclass", NULL);
rb_sGroupEntry = rb_struct_define("GroupEntry",
"sg_name","sg_passwd",
"sg_adm","sg_mem",NULL);
Expand Down
6 changes: 5 additions & 1 deletion shadow/shadow.c
Expand Up @@ -44,6 +44,7 @@ static VALUE convert_pw_struct( struct spwd *entry )
Qnil, /* used by BSD, pw_change, date when the password expires, in days since Jan 1, 1970 */
INT2FIX(entry->sp_expire),
INT2FIX(entry->sp_flag),
rb_tainted_str_new2(entry->pw_class),
NULL);
};
static VALUE
Expand Down Expand Up @@ -158,6 +159,7 @@ rb_shadow_putspent(VALUE self, VALUE entry, VALUE file)
centry.sp_inact = FIX2INT(val[6]);
centry.sp_expire = FIX2INT(val[8]);
centry.sp_flag = FIX2INT(val[9]);
centry.sp_loginclass = StringValuePtr(val[10]);

result = putspent(&centry,cfile);

Expand Down Expand Up @@ -243,7 +245,9 @@ Init_shadow()
rb_sPasswdEntry = rb_struct_define("PasswdEntry",
"sp_namp","sp_pwdp","sp_lstchg",
"sp_min","sp_max","sp_warn",
"sp_inact", "pw_change", "sp_expire","sp_flag", NULL);
"sp_inact", "pw_change",
"sp_expire","sp_flag",
"sp_loginclass", NULL);
rb_sGroupEntry = rb_struct_define("GroupEntry",
"sg_name","sg_passwd",
"sg_adm","sg_mem",NULL);
Expand Down

0 comments on commit bf04f51

Please sign in to comment.