[Kde-kiosk] Problem with Applying Group Profiles to new Users
Murray Trainer
mtrainer at central-data.net
Thu Jan 20 00:28:33 CET 2005
Martijn Klingens wrote:
>On Wednesday 19 January 2005 16:09, Murray Trainer wrote:
>
>
>>ldap:~ # cc -o test test.c
>>test.c: In function `main':
>>test.c:17: error: `for' loop initial declaration used outside C99 mode
>>test.c:19: error: `user' undeclared (first use in this function)
>>test.c:19: error: (Each undeclared identifier is reported only once
>>test.c:19: error: for each function it appears in.)
>>
>>
>
>Bah, the first error is only a reason to use C++ instead of C ;-)
>
>Anyway, the second error is a real one, I copy-pasted too much.
>
>Try this instead:
>
>-------
>#include <stdlib.h>
>#include <unistd.h>
>#include <sys/types.h>
>#include <pwd.h>
>#include <grp.h>
>
>int main( void )
>{
> char *member;
>
> struct passwd *pw = getpwuid(geteuid());
> if ( !pw )
> {
> printf( "Cannot read user info!\n" );
> return -1;
> }
> char *user = pw->pw_name;
>
> struct group *grp_ent = getgrnam( "external" );
> if (!grp_ent)
> {
> printf( "Cannot read group external!\n" );
> return -1;
> }
>
> char ** members = grp_ent->gr_mem;
> for( ; (member = *members); ++members )
> {
> if (strcmp(member, user) == 0)
> printf( "User is in group 'external'\n" );
> else
> printf( "User is *NOT* in group 'external'!\n" );
> }
> return 0;
>}
>-------
>
>Still untested, but at least there should be less errors now...
>
>
>
User mtrainer not in LDAP group external
Profile associated with external ldap group
sh-2.05b$ ./test
User is *NOT* in group 'external'!
User is *NOT* in group 'external'!
User is *NOT* in group 'external'!
User is in group 'external'
sh-2.05b$ groups mtrainer
mtrainer : users Domain Users
Kiosk Profile not working as expected
User mtrainer added in LDAP group external
sh-2.05b$ cd /tmp/mt
sh-2.05b$ groups mtrainer
mtrainer : users Domain Users external
sh-2.05b$ ./test
User is *NOT* in group 'external'!
User is *NOT* in group 'external'!
User is *NOT* in group 'external'!
User is in group 'external'
Profile not working but it should be
More information about the kde-kiosk
mailing list