Hi Henrik,
Il 20.49 06/07/2002 Henrik Nordstrom ha scritto:
>On Saturday 06 July 2002 17.39, Guido Serassio wrote:
>
> > >Note: If you need code for dealing with such strings there is a
> > >suitable strwordtok function in external_acl.c.. (not yet fully
> > >complete, but good enought for the job).
> > >
> > >Regards
> > >Henrik
> >
> > I have just looked it, but do You can explain how exactly works,
> > I'm not sure that I have understand this correctly.
>
>the strworktok function works sort of like strtok, except that it
>understands the \ escape syntax (partially) and quoting and unwinds
>it automatically, returning each string piece separately
Thanks, now is clear.
I have just included it, and now the new External ACL Winbind Group helper
seems to work fine.
I will make some more test and write some docs before release it.
Regards
Guido
>Example C skeleton for a external_acl group helper using the mentioned
>strwordtok function :
>
>#include <stdio.h>
>#include <syslog.h>
>#include <string.h>
>
>int main()
>{
> char buf[1024];
> char *user, *group;
> setbuf(stdout, NULL);
> openlog("helpername", 0, LOG_AUTHPRIV);
> while(fgets(buf, sizeof(buf), stdin)) {
> /* Some error management to deal with oversized lines */
> if (!strchr(buf, '\n')) {
> while(fgets(buf, sizeof(buf), stdin))
> if (strchr(buf, '\n'))
> break;
> syslog(LOG_NOTICE, "oversized request");
> printf("ERR\n");
> continue;
> }
>
> /* Split the input line in username and group */
> user = strwordtok(buf);
> group = strworktok(NULL);
>
> if (user_in_group(user, group))
> printf("OK\n");
> else
> printf("ERR\n");
> }
>}
>
>
>Regards
>Henrik
-
=======================================================
Serassio Guido
Via Albenga, 11/4 10134 - Torino - ITALY
E-mail: guido.serassio@serassio.it
WWW: http://www.serassio.it
Received on Sat Jul 06 2002 - 13:37:08 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:15:47 MST