diff options
Diffstat (limited to 'otherlibs/unix/initgroups.c')
-rw-r--r-- | otherlibs/unix/initgroups.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/otherlibs/unix/initgroups.c b/otherlibs/unix/initgroups.c new file mode 100644 index 000000000..ff81e8842 --- /dev/null +++ b/otherlibs/unix/initgroups.c @@ -0,0 +1,43 @@ +/***********************************************************************/ +/* */ +/* Objective Caml */ +/* */ +/* Copyright 2009 Institut National de Recherche en Informatique et */ +/* en Automatique. All rights reserved. This file is distributed */ +/* under the terms of the GNU Library General Public License, with */ +/* the special exception on linking described in file ../../LICENSE. */ +/* */ +/***********************************************************************/ + +/* Contributed by Stephane Glondu <steph@glondu.net> */ + +/* $Id$ */ + +#include <mlvalues.h> +#include <alloc.h> +#include <fail.h> + +#ifdef HAS_INITGROUPS + +#include <sys/types.h> +#ifdef HAS_UNISTD +#include <unistd.h> +#endif +#include <limits.h> +#include <grp.h> +#include "unixsupport.h" + +CAMLprim value unix_initgroups(value user, value group) +{ + if (initgroups(String_val(user), Int_val(group)) == -1) { + uerror("setgroups", Nothing); + } + return Val_unit; +} + +#else + +CAMLprim value unix_initgroups(value user, value group) +{ invalid_argument("initgroups not implemented"); } + +#endif |