diff --git a/src/modules/system/configure.in b/src/modules/system/configure.in index 75ab3b9b5e6eadd506a0c67373e4841e8021050a..2430ac69c9c32ed21a11c7bea6621caba5148746 100644 --- a/src/modules/system/configure.in +++ b/src/modules/system/configure.in @@ -15,7 +15,8 @@ AC_HAVE_HEADERS(syslog.h sys/syslog.h sys/types.h errno.h unistd.h pwd.h \ AC_HAVE_FUNCS(syslog link symlink readlink chown \ initgroups setgroups getgroups seteuid setresuid setegid setresgid \ geteuid getpgrp getpgid getppid getuid getgid setuid setgid \ - getpwnam getspnam getpwent setpwent endpwent \ + getpwnam getspnam getgrnam getpwuid getgrgid \ + getgrent setgrent endgrent getpwent setpwent endpwent \ chroot fchroot uname gethostname gethostbyname) diff --git a/src/modules/system/passwords.c b/src/modules/system/passwords.c index 321a635dfd345db282f3e23fbe22cdf6f62c00ac..6f962d781cf18fa79512e906a4e7f68b0cfbcd87 100644 --- a/src/modules/system/passwords.c +++ b/src/modules/system/passwords.c @@ -1,5 +1,5 @@ /* - * $Id: passwords.c,v 1.5 1997/12/07 22:00:27 grubba Exp $ + * $Id: passwords.c,v 1.6 1998/03/03 10:51:37 mast Exp $ * * Password handling for Pike. * @@ -15,7 +15,7 @@ #include "global.h" -RCSID("$Id: passwords.c,v 1.5 1997/12/07 22:00:27 grubba Exp $"); +RCSID("$Id: passwords.c,v 1.6 1998/03/03 10:51:37 mast Exp $"); #include "module_support.h" #include "interpret.h" @@ -28,12 +28,15 @@ RCSID("$Id: passwords.c,v 1.5 1997/12/07 22:00:27 grubba Exp $"); # include <passwd.h> # include <group.h> #endif /* HAVE_PASSWD_H */ - + #ifdef HAVE_PWD_H # include <pwd.h> -# include <grp.h> #endif /* HAVE_PWD_H */ - + +#ifdef HAVE_GRP_H +# include <grp.h> +#endif /* HAVE_GRP_H */ + #ifdef HAVE_SHADOW_H # include <shadow.h> #endif /* HAVE_SHADOW_H */ @@ -42,7 +45,7 @@ RCSID("$Id: passwords.c,v 1.5 1997/12/07 22:00:27 grubba Exp $"); * Functions */ -#if defined(HAVE_GETPWNAM) || defined(HAVE_GETPWUID) || defined(HAVE_SETPWENT) || defined(HAVE_ENDPWENT) || defined(HAVE_GETPWENT) +#if defined(HAVE_GETPWNAM) || defined(HAVE_GETPWUID) || defined(HAVE_GETPWENT) static void push_pwent(struct passwd *ent) { if(!ent) @@ -70,7 +73,9 @@ static void push_pwent(struct passwd *ent) push_text(ent->pw_shell); f_aggregate(7); } +#endif +#if defined(HAVE_GETGRNAM) || defined(HAVE_GETGRUID) || defined(HAVE_GETGRENT) static void push_grent(struct group *ent) { if(!ent) @@ -90,9 +95,9 @@ static void push_grent(struct group *ent) f_aggregate(4); } #endif - -#ifdef HAVE_GETPWNAM -/* array getpwnam(string str) */ + +#ifdef HAVE_GETGRGID +/* array getgrgid(int gid) */ void f_getgrgid(INT32 args) { int gid; @@ -102,17 +107,23 @@ void f_getgrgid(INT32 args) pop_n_elems( args ); push_grent( foo ); } +#endif /* HAVE_GETGRGID */ +#ifdef HAVE_GETGRNAM +/* array getgrnam(string str) */ void f_getgrnam(INT32 args) { char *str; struct group *foo; - get_all_args("getpwnam", args, "%s", &str); + get_all_args("getgrnam", args, "%s", &str); foo = getgrnam( str ); pop_n_elems( args ); push_grent( foo ); } +#endif /* HAVE_GETGRNAM */ +#ifdef HAVE_GETPWNAM +/* array getpwnam(string str) */ void f_getpwnam(INT32 args) { char *str; @@ -125,7 +136,9 @@ void f_getpwnam(INT32 args) pop_n_elems(args); push_pwent(foo); } +#endif /* HAVE_GETPWNAM */ +#ifdef HAVE_GETPWUID /* array getpwuid(int uid) */ void f_getpwuid(INT32 args) { @@ -139,8 +152,8 @@ void f_getpwuid(INT32 args) pop_n_elems(args); push_pwent(foo); } -#endif - +#endif /* HAVE_GETPWUID */ + #ifdef HAVE_SETPWENT /* int setpwent() */ void f_setpwent(INT32 args) @@ -151,7 +164,7 @@ void f_setpwent(INT32 args) } #endif /* HAVE_SETPWENT */ -#ifdef HAVE_GETPWENT +#ifdef HAVE_ENDPWENT /* int endpwent() */ void f_endpwent(INT32 args) { @@ -159,7 +172,9 @@ void f_endpwent(INT32 args) pop_n_elems(args); push_int(0); } +#endif /* HAVE_ENDPWENT */ +#ifdef HAVE_GETPWENT /* int|array getpwent() */ void f_getpwent(INT32 args) { @@ -173,6 +188,40 @@ void f_getpwent(INT32 args) } push_pwent(foo); } - #endif /* HAVE_GETPWENT */ - + +#ifdef HAVE_SETGRENT +/* int setgrent() */ +void f_setgrent(INT32 args) +{ + setgrent(); + pop_n_elems(args); + push_int(0); +} +#endif /* HAVE_SETGRENT */ + +#ifdef HAVE_ENDGRENT +/* int endgrent() */ +void f_endgrent(INT32 args) +{ + endgrent(); + pop_n_elems(args); + push_int(0); +} +#endif /* HAVE_ENDGRENT */ + +#ifdef HAVE_GETGRENT +/* int|array getgrent() */ +void f_getgrent(INT32 args) +{ + struct group *foo; + pop_n_elems(args); + foo = getgrent(); + if(!foo) + { + push_int(0); + return; + } + push_grent(foo); +} +#endif /* HAVE_GETGRENT */ diff --git a/src/modules/system/system.c b/src/modules/system/system.c index 918f9bfce86f19201522ac0d4a023acf66d4e90e..62df9dc8bf9da880e738e3c1f0910c03cd052202 100644 --- a/src/modules/system/system.c +++ b/src/modules/system/system.c @@ -1,5 +1,5 @@ /* - * $Id: system.c,v 1.42 1998/02/27 08:41:45 hubbe Exp $ + * $Id: system.c,v 1.43 1998/03/03 10:51:38 mast Exp $ * * System-call module for Pike * @@ -14,7 +14,7 @@ #include "system.h" #include "global.h" -RCSID("$Id: system.c,v 1.42 1998/02/27 08:41:45 hubbe Exp $"); +RCSID("$Id: system.c,v 1.43 1998/03/03 10:51:38 mast Exp $"); #ifdef HAVE_WINSOCK_H #include <winsock.h> #endif @@ -1046,20 +1046,37 @@ void pike_module_init(void) #ifdef HAVE_GETPWNAM add_efun("getpwnam", f_getpwnam, "function(string:array)", OPT_EXTERNAL_DEPEND); +#endif +#ifdef HAVE_GETPWUID add_efun("getpwuid", f_getpwuid, "function(int:array)", OPT_EXTERNAL_DEPEND); - +#endif +#ifdef HAVE_GETGRNAM add_efun("getgrnam", f_getgrnam, "function(string:array)", OPT_EXTERNAL_DEPEND); +#endif +#ifdef HAVE_GETGRGID add_efun("getgrgid", f_getgrgid, "function(int:array)", OPT_EXTERNAL_DEPEND); #endif #ifdef HAVE_GETPWENT add_efun("getpwent", f_getpwent, "function(void:int|array)", OPT_EXTERNAL_DEPEND); +#endif +#ifdef HAVE_ENDPWENT add_efun("endpwent", f_endpwent, "function(void:int)", OPT_EXTERNAL_DEPEND); #endif #ifdef HAVE_SETPWENT add_efun("setpwent", f_setpwent, "function(void:int)", OPT_EXTERNAL_DEPEND); #endif +#ifdef HAVE_GETGRENT + add_efun("getgrent", f_getgrent, "function(void:int|array)", + OPT_EXTERNAL_DEPEND); +#endif +#ifdef HAVE_ENDGRENT + add_efun("endgrent", f_endgrent, "function(void:int)", OPT_EXTERNAL_DEPEND); +#endif +#ifdef HAVE_SETGRENT + add_efun("setgrent", f_setgrent, "function(void:int)", OPT_EXTERNAL_DEPEND); +#endif #ifdef GETHOSTBYNAME_MUTEX_EXISTS add_to_callback(& fork_child_callback, cleanup_after_fork, 0, 0); diff --git a/src/modules/system/system.h b/src/modules/system/system.h index 776c769244f6165df5f403670a27a2fbbc972806..acb73370336f239e39241d9a3b5bcaaf8ac85aa0 100644 --- a/src/modules/system/system.h +++ b/src/modules/system/system.h @@ -1,5 +1,5 @@ /* - * $Id: system.h,v 1.3 1998/02/24 23:10:25 hubbe Exp $ + * $Id: system.h,v 1.4 1998/03/03 10:51:38 mast Exp $ * * Prototypes for the Pike system-module * @@ -30,6 +30,9 @@ void f_getpwuid(INT32 args); void f_setpwent(INT32 args); void f_endpwent(INT32 args); void f_getpwent(INT32 args); +void f_setgrent(INT32 args); +void f_endgrent(INT32 args); +void f_getgrent(INT32 args); /* * syslog.c