SWAT patches ..

harris at hightide.net.au harris at hightide.net.au
Sat Jun 27 03:02:29 GMT 1998


Mornin' all, 
	Two patches enclosed so that swat does pull down lists of users
for things like "valid users = foo bar" instead of a text field. Right now
it depends on them being set as P_USERS in loadparm.c.

	It has all the sophistication of a "Hello world!" program because,
well, it is.. Hopefully someone else can turn it into something vaguely
useful. It doesn't cope with a seperate passwd file for samba because it
relies on getpwent(), I can't geet the hang of using sizeof(), so it's a
buffer overflow waiting to happen. Also my first contribution to a GPL'd
project and I'm proud of it beyond all relation to it's actual worth, so
be nice to me ;).

--

Harris Vaegan-Lloyd     ~HIGHTIDE~      Hightide Internet Pty Limited
                        ~~~~~~~~~~      http://www.hightide.net.au
                                        Tel: +61 - 2 - 9960 0069
mailto:harris at hightide.net.au           Fax: +61 - 2 - 9960 8006

-------------- next part --------------
29a30
> #define MAXUSERS 100
31d31
< static pstring servicesf = CONFIGFILE;
32a33
> static pstring servicesf = CONFIGFILE;
91a93,106
> /* Function to put a list of all users into an array of pointers. */
> int get_users ( char *users[]) {
> 
>         int c, i;
>         char *p;
>         struct passwd *cur;
>         for ( i = 0 ; cur = getpwent() ; i++ ) {
>                 users[i] = malloc(64);
>                 strcpy(users[i], cur->pw_name);
>         }
>         return i;
> }
> 
> 
121c136
< static void show_parameter(int snum, struct parm_struct *parm)
---
> static void show_parameter(int snum, struct parm_struct *parm, char *users[])
123a139
> 	int y;
124a141
> 	char *x;
196a214,224
> 	case P_USERS:
> 		x = malloc(10000); /* This is ugly - Care to fix it ? I can't ;( */
> 		sprintf(x, "%s", *(char **)ptr); /* This is also ugly see above .. */
> 		printf("<select name=\"parm_%s\" size = 4 multiple>\n", make_parm_name(parm->label));
> 		for (i=0; users[i] ; i++)
> 			printf("<option %s %s> %s \n", users[i], strstr(x,users[i])?"selected":"", users[i]);
> 		printf("</select>\n");
> 		break;
> 	case P_GROUPS:
> 		printf("<h1> Groups Section Goes here. </H1>");
> 		break;
202c230
< static void show_parameters(int snum, int allparameters, int advanced, int printers)
---
> static void show_parameters(int snum, int allparameters, int advanced, int printers, char *users[])
260c288
< 		show_parameter(snum, parm);
---
> 		show_parameter(snum, parm, users);
332c360
< 		slprintf(label, sizeof(label)-1, "parm_%s", make_parm_name(parm->label));
---
> 		sprintf(label, "parm_%s", make_parm_name(parm->label));
411a440,442
> 	char *users[MAXUSERS];
> 	
> 	get_users( users );
435c466
< 	show_parameters(GLOBALS_SNUM, 1, advanced, 0);
---
> 	show_parameters(GLOBALS_SNUM, 1, advanced, 0, users);
449a481
> 	char *users[MAXUSERS];
453a486,487
> 	get_users(users);
> 
515c549
< 		show_parameters(snum, 1, advanced, 0);
---
> 		show_parameters(snum, 1, advanced, 0, users);
531a566
> 	char *users[MAXUSERS];
535a571,572
> 	get_users(users);
> 
599c636
< 		show_parameters(snum, 1, advanced, 1);
---
> 		show_parameters(snum, 1, advanced, 1, users);
-------------- next part --------------
242a243,250
> 	int x;
> 	char *var;
> 	char *swap;
> 	x = 0;
> 	swap = malloc(2000);
> 	var = malloc(2000);
> 	strcpy(swap, "");
> 	strcpy(var, "");
244,247c252,268
< 	for (i=0;i<num_variables;i++)
< 		if (strcmp(variables[i].name, name) == 0)
< 			return variables[i].value;
< 	return NULL;
---
> 	for (i=0;i<num_variables;i++) {
> 		if (strcmp(variables[i].name, name) == 0) {
> 			strcpy(swap, var);
> 			if (x) {
> 				sprintf(var, "%s %s", variables[i].value, swap);
> 			} else {
> 				sprintf(var, "%s", variables[i].value);
> 			}
> 			x = 1;
> 		}
> 	}
> 
> 	if (x) {
> 		return var;
> 	} else {
> 		return NULL;
> 	}


More information about the samba-technical mailing list