Mercurial > noffle
comparison src/group.c @ 228:1ad2602f57db noffle
[svn] see Changelog Dec 18 2001
author | mirkol |
---|---|
date | Tue, 18 Dec 2001 15:27:08 +0000 |
parents | 24d4cd032da5 |
children | 6eb6c912a0e4 |
comparison
equal
deleted
inserted
replaced
227:c48d7e881a21 | 228:1ad2602f57db |
---|---|
5 the groups we know of. One database record is cached in the global struct | 5 the groups we know of. One database record is cached in the global struct |
6 grp. Group information is transfered between the grp and the database by | 6 grp. Group information is transfered between the grp and the database by |
7 loadGrp() and saveGrp(). This is done transparently. Access to the groups | 7 loadGrp() and saveGrp(). This is done transparently. Access to the groups |
8 database is done by group name, by the functions defined in group.h. | 8 database is done by group name, by the functions defined in group.h. |
9 | 9 |
10 $Id: group.c 316 2001-10-31 11:44:53Z bears $ | 10 $Id: group.c 358 2001-12-18 15:27:08Z mirkol $ |
11 */ | 11 */ |
12 | 12 |
13 #if HAVE_CONFIG_H | 13 #if HAVE_CONFIG_H |
14 #include <config.h> | 14 #include <config.h> |
15 #endif | 15 #endif |
409 cursor = gdbm_nextkey( grp.dbf, cursor ); | 409 cursor = gdbm_nextkey( grp.dbf, cursor ); |
410 free( oldDptr ); | 410 free( oldDptr ); |
411 *name = cursor.dptr; | 411 *name = cursor.dptr; |
412 return ( cursor.dptr != NULL ); | 412 return ( cursor.dptr != NULL ); |
413 } | 413 } |
414 | |
415 Bool | |
416 Grp_isValidGroupName( const char *name) | |
417 { | |
418 const char *pname, *ppat; | |
419 const char *illegalchars = "\t\n\r,"; /* Are there any other illegal characters? */ | |
420 | |
421 /* Find directory prefixes to prevent exploits. */ | |
422 switch ( name[0] ) | |
423 { | |
424 case '.': /* prevent noffle -C ../fetchlist */ | |
425 case '/': /* prevent noffle -C /etc/noffle.conf */ | |
426 case ':': | |
427 case '\\': | |
428 return FALSE; /* group name invalid */ | |
429 } | |
430 | |
431 /* Find illegal characters. */ | |
432 if ( strpbrk( name, illegalchars ) ) | |
433 return FALSE; | |
434 | |
435 /* Find "all", "all.*", "*.all" or "*.all.*" */ | |
436 pname = name; | |
437 while ( ppat = strstr( pname, "all" ) ) | |
438 { | |
439 if ( ( ppat == name || *(ppat - 1) == '.' ) | |
440 && ( *(ppat+4) == '\0' || *(ppat+4) == '.' ) ) | |
441 return FALSE; | |
442 else | |
443 pname += 3; | |
444 } | |
445 | |
446 /* Group name is hopefully valid. */ | |
447 return TRUE; | |
448 } |