[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-hackers] [PATCH 3/3] Remove group-information and {get, set, in
From: |
Evan Hanson |
Subject: |
[Chicken-hackers] [PATCH 3/3] Remove group-information and {get, set, initialize}-groups from unit posix |
Date: |
Sat, 4 Jun 2016 00:03:25 +1200 |
These procedures have been moved to an egg.
---
Makefile.aix | 1 -
Makefile.android | 1 -
Makefile.bsd | 1 -
Makefile.cygwin | 1 -
Makefile.haiku | 1 -
Makefile.hurd | 1 -
Makefile.ios | 1 -
Makefile.linux | 1 -
Makefile.macosx | 1 -
Makefile.solaris | 1 -
NEWS | 7 ++--
manual/Unit posix | 40 +------------------
posixunix.scm | 112 +++---------------------------------------------------
posixwin.scm | 19 ++++-----
types.db | 4 --
15 files changed, 18 insertions(+), 174 deletions(-)
diff --git a/Makefile.aix b/Makefile.aix
index 6cc6891..3884dce 100644
--- a/Makefile.aix
+++ b/Makefile.aix
@@ -91,7 +91,6 @@ chicken-config.h: chicken-defaults.h
echo "#define STDC_HEADERS 1" >>$@
echo "#define HAVE_ALLOCA 1" >>$@
echo "#define HAVE_ALLOCA_H 1" >>$@
- echo "#define HAVE_GRP_H 1" >>$@
echo "#define HAVE_ERRNO_H 1" >>$@
echo "#define HAVE_SYSEXITS_H 1" >>$@
echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@
diff --git a/Makefile.android b/Makefile.android
index 23c8e63..c48b4f7 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -85,7 +85,6 @@ chicken-config.h: chicken-defaults.h
echo "#define STDC_HEADERS 1" >>$@
echo "#define HAVE_ALLOCA 1" >>$@
echo "#define HAVE_ALLOCA_H 1" >>$@
- echo "#define HAVE_GRP_H 1" >>$@
echo "#define HAVE_ERRNO_H 1" >>$@
echo "#define HAVE_MEMMOVE 1" >>$@
echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@
diff --git a/Makefile.bsd b/Makefile.bsd
index 1444b7a..bf64a15 100644
--- a/Makefile.bsd
+++ b/Makefile.bsd
@@ -91,7 +91,6 @@ chicken-config.h: chicken-defaults.h
echo "#define HAVE_UNSIGNED_LONG_LONG 1" >>$@
echo "#define STDC_HEADERS 1" >>$@
echo "#define HAVE_ALLOCA 1" >>$@
- echo "#define HAVE_GRP_H 1" >>$@
echo "#define HAVE_ERRNO_H 1" >>$@
echo "#define HAVE_SYSEXITS_H 1" >>$@
echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@
diff --git a/Makefile.cygwin b/Makefile.cygwin
index 87e866b..b4587f5 100644
--- a/Makefile.cygwin
+++ b/Makefile.cygwin
@@ -104,7 +104,6 @@ chicken-config.h: chicken-defaults.h
echo "#define STDC_HEADERS 1" >>$@
echo "#define HAVE_ALLOCA 1" >>$@
echo "#define HAVE_ALLOCA_H 1" >>$@
- echo "#define HAVE_GRP_H 1" >>$@
echo "#define HAVE_ERRNO_H 1" >>$@
echo "#define HAVE_SYSEXITS_H 1" >>$@
echo "#define HAVE_DLFCN_H 1" >>$@
diff --git a/Makefile.haiku b/Makefile.haiku
index f271144..11787e0 100644
--- a/Makefile.haiku
+++ b/Makefile.haiku
@@ -84,7 +84,6 @@ chicken-config.h: chicken-defaults.h
echo "#define STDC_HEADERS 1" >>$@
echo "#define HAVE_ALLOCA 1" >>$@
echo "#define HAVE_ALLOCA_H 1" >>$@
- echo "#define HAVE_GRP_H 1" >>$@
echo "#define HAVE_ERRNO_H 1" >>$@
echo "#define HAVE_MEMMOVE 1" >>$@
echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@
diff --git a/Makefile.hurd b/Makefile.hurd
index a8f703c..1feb580 100644
--- a/Makefile.hurd
+++ b/Makefile.hurd
@@ -85,7 +85,6 @@ chicken-config.h: chicken-defaults.h
echo "#define STDC_HEADERS 1" >>$@
echo "#define HAVE_ALLOCA 1" >>$@
echo "#define HAVE_ALLOCA_H 1" >>$@
- echo "#define HAVE_GRP_H 1" >>$@
echo "#define HAVE_ERRNO_H 1" >>$@
echo "#define HAVE_SYSEXITS_H 1" >>$@
echo "#define HAVE_MEMMOVE 1" >>$@
diff --git a/Makefile.ios b/Makefile.ios
index 54b88b3..70a5f27 100644
--- a/Makefile.ios
+++ b/Makefile.ios
@@ -89,7 +89,6 @@ chicken-config.h: chicken-defaults.h
echo "#define STDC_HEADERS 1" >>$@
echo "#define HAVE_ALLOCA 1" >>$@
echo "#define HAVE_ALLOCA_H 1" >>$@
- echo "#define HAVE_GRP_H 1" >>$@
echo "#define HAVE_ERRNO_H 1" >>$@
echo "#define HAVE_SYSEXITS_H 1" >>$@
echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@
diff --git a/Makefile.linux b/Makefile.linux
index 4ec121c..276f9ff 100644
--- a/Makefile.linux
+++ b/Makefile.linux
@@ -92,7 +92,6 @@ chicken-config.h: chicken-defaults.h
echo "#define STDC_HEADERS 1" >>$@
echo "#define HAVE_ALLOCA 1" >>$@
echo "#define HAVE_ALLOCA_H 1" >>$@
- echo "#define HAVE_GRP_H 1" >>$@
echo "#define HAVE_ERRNO_H 1" >>$@
echo "#define HAVE_SYSEXITS_H 1" >>$@
echo "#define HAVE_MEMMOVE 1" >>$@
diff --git a/Makefile.macosx b/Makefile.macosx
index d480032..13792bd 100644
--- a/Makefile.macosx
+++ b/Makefile.macosx
@@ -113,7 +113,6 @@ chicken-config.h: chicken-defaults.h
echo "#define STDC_HEADERS 1" >>$@
echo "#define HAVE_ALLOCA 1" >>$@
echo "#define HAVE_ALLOCA_H 1" >>$@
- echo "#define HAVE_GRP_H 1" >>$@
echo "#define HAVE_CRT_EXTERNS_H 1" >>$@
echo "#define HAVE_ERRNO_H 1" >>$@
echo "#define HAVE_SYSEXITS_H 1" >>$@
diff --git a/Makefile.solaris b/Makefile.solaris
index 583c924..c290665 100644
--- a/Makefile.solaris
+++ b/Makefile.solaris
@@ -115,7 +115,6 @@ chicken-config.h: chicken-defaults.h
echo "#define STDC_HEADERS 1" >>$@
echo "#define HAVE_ALLOCA_H 1" >>$@
echo "#define HAVE_ALLOCA 1" >>$@
- echo "#define HAVE_GRP_H 1" >>$@
echo "#define HAVE_ERRNO_H 1" >>$@
echo "#define HAVE_SYSEXITS_H 1" >>$@
echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@
diff --git a/NEWS b/NEWS
index 2c539a4..5c6a36f 100644
--- a/NEWS
+++ b/NEWS
@@ -16,9 +16,10 @@
- The new "-link" option to csc allows linking with objects from extensions.
- Core libraries
- - Removed support for memory-mapped files (posix), queues (data-structures),
- binary-search (data-structures), scan-input-lines (utils), and
- object-eviction (lolevel). These are now available as eggs.
+ - Removed support for memory-mapped files (posix), queues
+ (data-structures), binary-search (data-structures), scan-input-lines
+ (utils), group-information (posix) and object-eviction (lolevel).
+ These are now available as eggs.
- Removed the srfi-1, srfi-13, srfi-14, srfi-18 and srfi-69 units.
These are now available as eggs.
- Added the `executable-pathname` procedure for retrieving a path to
diff --git a/manual/Unit posix b/manual/Unit posix
index 0456fb8..72b448d 100644
--- a/manual/Unit posix
+++ b/manual/Unit posix
@@ -838,41 +838,6 @@ Get or set the real group-id of the current process.
Get or set the effective group-id of the current process.
ID can be found, then {{#f}} is returned.
-==== group-information
-
-<procedure>(group-information GROUP)</procedure>
-
-If {{GROUP}} specifies a valid group-name or group-id, then this
-procedure returns a list of four values: the group-name, the encrypted group
password,
-the group ID and a list of the names of all group members. If no group with the
-given name or ID exists, then {{#f}} is returned.
-
-==== get-groups
-
-<procedure>(get-groups)</procedure>
-
-Returns a list with the supplementary group IDs of the current user.
-
-
-=== Changing user & group information
-
-==== set-groups!
-
-<procedure>(set-groups! GIDLIST)</procedure>
-
-Sets the supplementrary group IDs of the current user to the IDs given in the
list {{GIDLIST}}.
-
-Only the superuser may invoke this procedure.
-
-==== initialize-groups
-
-<procedure>(initialize-groups USERNAME BASEGID)</procedure>
-
-Sets the supplementrary group IDs of the current user to the IDs from the user
with name {{USERNAME}}
-(a string), including {{BASEGID}}.
-
-Only the superuser may invoke this procedure.
-
=== Record locking
@@ -1302,9 +1267,7 @@ not be obtained. On Windows, this procedure always
returns {{0}},
; {{file-unlock}} : {{fcntl}}
; {{file-write}} : {{write}}
; {{file-write-access?}} : {{access}}
-; {{get-groups}} : {{getgroups}}
; {{get-host-name}} : {{gethostname}}
-; {{initialize-groups}} : {{initgroups}}
; {{local-time->seconds}} : {{mktime}}
; {{local-timezone-abbreviation}} : {{localtime}}
; {{open-input-file*}} : {{fdopen}}
@@ -1326,7 +1289,6 @@ not be obtained. On Windows, this procedure always
returns {{0}},
; {{set-alarm!}} : {{alarm}}
; {{set-buffering-mode!}} : {{setvbuf}}
; {{set-file-position!}} : {{fseek/seek}}
-; {{set-groups!}} : {{setgroups}}
; {{set-signal-mask!}} : {{sigprocmask}}
; {{set-group-id!}} : {{setgid}}
; {{set-user-id!}} : {{setuid}}
@@ -1380,7 +1342,7 @@ Microsoft tools or with MinGW):
file-select file-control
signal/... (except signal/term, signal/int, signal/fpe, signal/ill,
signal/segv, signal/abrt, signal/break)
set-signal-mask! signal-mask signal-masked? signal-mask! signal-unmask!
- user-information group-information get-groups set-groups!
initialize-groups
+ user-information
errno/wouldblock
change-directory*
change-file-owner
diff --git a/posixunix.scm b/posixunix.scm
index d358d84..671064e 100644
--- a/posixunix.scm
+++ b/posixunix.scm
@@ -53,11 +53,11 @@
file-position set-file-position! file-read file-read-access?
file-select file-size file-stat file-test-lock file-truncate
file-type file-unlock file-write file-write-access? fileno/stderr
- fileno/stdin fileno/stdout find-files get-groups get-host-name glob
- group-information initialize-groups local-time->seconds
- local-timezone-abbreviation open-input-file* open-input-pipe
- open-output-file* open-output-pipe open/append open/binary open/creat
- open/excl open/fsync open/noctty open/nonblock open/rdonly open/rdwr
+ fileno/stdin fileno/stdout find-files get-host-name glob
+ local-time->seconds local-timezone-abbreviation
+ open-input-file* open-input-pipe open-output-file* open-output-pipe
+ open/append open/binary open/creat open/excl open/fsync
+ open/noctty open/nonblock open/rdonly open/rdwr
open/read open/sync open/text open/trunc open/write open/wronly
parent-process-id perm/irgrp perm/iroth perm/irusr perm/irwxg
perm/irwxo perm/irwxu perm/isgid perm/isuid perm/isvtx perm/iwgrp
@@ -66,7 +66,7 @@
process-group-id process-run process-signal process-wait
read-symbolic-link regular-file? seconds->local-time seconds->string
seconds->utc-time seek/cur seek/end seek/set set-alarm!
- set-buffering-mode! set-groups! set-root-directory!
+ set-buffering-mode! set-root-directory!
set-signal-handler! set-signal-mask! signal-handler
signal-mask signal-mask! signal-masked? signal-unmask! signal/abrt
signal/alrm signal/break signal/chld signal/cont signal/fpe
@@ -108,10 +108,6 @@ static C_TLS int C_wait_status;
# include <termios.h>
#endif
-#ifdef HAVE_GRP_H
-#include <grp.h>
-#endif
-
#include <sys/mman.h>
#include <sys/poll.h>
@@ -170,15 +166,6 @@ static C_TLS struct utsname C_utsname;
static C_TLS struct flock C_flock;
static C_TLS DIR *temphandle;
static C_TLS struct passwd *C_user;
-#ifdef HAVE_GRP_H
-static C_TLS struct group *C_group;
-#else
-static C_TLS struct {
- char *gr_name, gr_passwd;
- int gr_gid;
- char *gr_mem[ 1 ];
-} C_group = { "", "", 0, { "" } };
-#endif
/* Android doesn't provide pw_gecos in the passwd struct */
#ifdef __ANDROID__
@@ -225,13 +212,6 @@ static C_TLS struct stat C_statbuf;
#define C_do_readlink(f, b) C_fix(readlink(C_data_pointer(f),
C_data_pointer(b), FILENAME_MAX))
#define C_getpwnam(n) C_mk_bool((C_user = getpwnam((char
*)C_data_pointer(n))) != NULL)
#define C_getpwuid(u) C_mk_bool((C_user = getpwuid(C_unfix(u))) != NULL)
-#if !defined(__ANDROID__) && defined(HAVE_GRP_H)
-#define C_getgrnam(n) C_mk_bool((C_group = getgrnam((char
*)C_data_pointer(n))) != NULL)
-#define C_getgrgid(u) C_mk_bool((C_group = getgrgid(C_unfix(u))) != NULL)
-#else
-#define C_getgrnam(n) C_SCHEME_FALSE
-#define C_getgrgid(n) C_SCHEME_FALSE
-#endif
#define C_pipe(d) C_fix(pipe(C_pipefds))
#define C_truncate(f, n) C_fix(truncate((char *)C_data_pointer(f),
C_num_to_int(n)))
#define C_ftruncate(f, n) C_fix(ftruncate(C_unfix(f), C_num_to_int(n)))
@@ -386,12 +366,6 @@ C_tm_get( C_word v, void *tm )
#define C_strptime(s, f, v, stm) \
(strptime(C_c_string(s), C_c_string(f), ((struct tm *)(stm))) ?
C_tm_get((v), (stm)) : C_SCHEME_FALSE)
-static gid_t *C_groups = NULL;
-
-#define C_get_gid(n) C_fix(C_groups[ C_unfix(n) ])
-#define C_set_gid(n, id) (C_groups[ C_unfix(n) ] = C_unfix(id),
C_SCHEME_UNDEFINED)
-#define C_set_groups(n) C_fix(setgroups(C_unfix(n), C_groups))
-
#if !defined(__ANDROID__) && defined(TIOCGWINSZ)
static int get_tty_size(int p, int *rows, int *cols)
{
@@ -972,80 +946,6 @@ EOF
(define (current-effective-user-name)
(car (user-information (current-effective-user-id))) )
-(define-foreign-variable _group-name nonnull-c-string "C_group->gr_name")
-(define-foreign-variable _group-passwd nonnull-c-string "C_group->gr_passwd")
-(define-foreign-variable _group-gid int "C_group->gr_gid")
-
-(define group-member
- (foreign-lambda* c-string ([int i])
- "C_return(C_group->gr_mem[ i ]);") )
-
-(define (group-information group #!optional as-vector)
- (let ([r (if (fixnum? group)
- (##core#inline "C_getgrgid" group)
- (begin
- (##sys#check-string group 'group-information)
- (##core#inline "C_getgrnam" (##sys#make-c-string group
'group-information)) ) ) ] )
- (and r
- ((if as-vector vector list)
- _group-name
- _group-passwd
- _group-gid
- (let loop ([i 0])
- (let ([n (group-member i)])
- (if n
- (cons n (loop (fx+ i 1)))
- '() ) ) ) ) ) ) )
-
-(define _get-groups
- (foreign-lambda* int ([int n])
- "C_return(getgroups(n, C_groups));") )
-
-(define _ensure-groups
- (foreign-lambda* bool ([int n])
- "if(C_groups != NULL) C_free(C_groups);"
- "C_groups = (gid_t *)C_malloc(sizeof(gid_t) * n);"
- "if(C_groups == NULL) C_return(0);"
- "else C_return(1);") )
-
-(define (get-groups)
- (let ([n (foreign-value "getgroups(0, C_groups)" int)])
- (when (fx< n 0)
- (##sys#update-errno)
- (##sys#error 'get-groups "cannot retrieve supplementary group ids") )
- (unless (_ensure-groups n)
- (##sys#error 'get-groups "out of memory") )
- (when (fx< (_get-groups n) 0)
- (##sys#update-errno)
- (##sys#error 'get-groups "cannot retrieve supplementary group ids") )
- (let loop ([i 0])
- (if (fx>= i n)
- '()
- (cons (##core#inline "C_get_gid" i) (loop (fx+ i 1))) ) ) ) )
-
-(define (set-groups! lst0)
- (unless (_ensure-groups (length lst0))
- (##sys#error 'set-groups! "out of memory") )
- (do ([lst lst0 (##sys#slot lst 1)]
- [i 0 (fx+ i 1)] )
- ((null? lst)
- (when (fx< (##core#inline "C_set_groups" i) 0)
- (##sys#update-errno)
- (##sys#error 'set-groups! "cannot set supplementary group ids" lst0) ) )
- (let ([n (##sys#slot lst 0)])
- (##sys#check-fixnum n 'set-groups!)
- (##core#inline "C_set_gid" i n) ) ) )
-
-(define initialize-groups
- (let ([init (foreign-lambda int "initgroups" c-string int)])
- (lambda (user id)
- (##sys#check-string user 'initialize-groups)
- (##sys#check-fixnum id 'initialize-groups)
- (when (fx< (init user id) 0)
- (##sys#update-errno)
- (##sys#error 'initialize-groups "cannot initialize supplementary group
ids" user id) ) ) ) )
-
-
;;; Permissions and owners:
(define change-file-mode
diff --git a/posixwin.scm b/posixwin.scm
index b1ce436..7f6611a 100644
--- a/posixwin.scm
+++ b/posixwin.scm
@@ -32,7 +32,7 @@
; file-select
; symbolic-link?
; set-signal-mask! signal-mask signal-masked? signal-mask!
signal-unmask!
-; user-information group-information get-groups set-groups!
initialize-groups
+; user-information
; change-directory*
; change-file-owner
; current-user-id current-group-id current-effective-user-id
current-effective-group-id
@@ -88,7 +88,6 @@
static C_TLS char *C_exec_args[ ARG_MAX ];
static C_TLS char *C_exec_env[ ENV_MAX ];
-static C_TLS struct group *C_group;
static C_TLS int C_pipefds[ 2 ];
static C_TLS time_t C_secs;
@@ -677,11 +676,11 @@ EOF
file-position set-file-position! file-read file-read-access?
file-select file-size file-stat file-test-lock file-truncate
file-type file-unlock file-write file-write-access? fileno/stderr
- fileno/stdin fileno/stdout find-files get-groups get-host-name glob
- group-information initialize-groups local-time->seconds
- local-timezone-abbreviation open-input-file* open-input-pipe
- open-output-file* open-output-pipe open/append open/binary open/creat
- open/excl open/fsync open/noctty open/nonblock open/rdonly open/rdwr
+ fileno/stdin fileno/stdout find-files get-host-name glob
+ local-time->seconds local-timezone-abbreviation
+ open-input-file* open-input-pipe open-output-file* open-output-pipe
+ open/append open/binary open/creat open/excl open/fsync
+ open/noctty open/nonblock open/rdonly open/rdwr
open/read open/sync open/text open/trunc open/write open/wronly
parent-process-id perm/irgrp perm/iroth perm/irusr perm/irwxg
perm/irwxo perm/irwxu perm/isgid perm/isuid perm/isvtx perm/iwgrp
@@ -690,7 +689,7 @@ EOF
process-group-id process-run process-signal process-wait
read-symbolic-link regular-file? seconds->local-time seconds->string
seconds->utc-time seek/cur seek/end seek/set set-alarm!
- set-buffering-mode! set-groups! set-root-directory!
+ set-buffering-mode! set-root-directory!
set-signal-handler! set-signal-mask! signal-handler
signal-mask signal-mask! signal-masked? signal-unmask! signal/abrt
signal/alrm signal/break signal/chld signal/cont signal/fpe
@@ -1399,9 +1398,6 @@ EOF
(define-unimplemented file-test-lock)
(define-unimplemented file-truncate)
(define-unimplemented file-unlock)
-(define-unimplemented get-groups)
-(define-unimplemented group-information)
-(define-unimplemented initialize-groups)
(define-unimplemented parent-process-id)
(define-unimplemented process-fork)
(define-unimplemented process-group-id)
@@ -1409,7 +1405,6 @@ EOF
(define-unimplemented read-symbolic-link)
(define-unimplemented set-alarm!)
(define-unimplemented set-group-id!)
-(define-unimplemented set-groups!)
(define-unimplemented set-process-group-id!)
(define-unimplemented set-root-directory!)
(define-unimplemented set-signal-mask!)
diff --git a/types.db b/types.db
index a05bb1d..7b1e1f1 100644
--- a/types.db
+++ b/types.db
@@ -1959,11 +1959,8 @@
(chicken.posix#fileno/stdin fixnum)
(chicken.posix#fileno/stdout fixnum)
(chicken.posix#find-files (#(procedure #:enforce) chicken.posix#find-files
(string #!rest) list))
-(chicken.posix#get-groups (#(procedure #:clean) chicken.posix#get-groups ()
list))
(chicken.posix#get-host-name (#(procedure #:clean) chicken.posix#get-host-name
() string))
(chicken.posix#glob (#(procedure #:clean #:enforce) chicken.posix#glob (#!rest
string) list))
-(chicken.posix#group-information (#(procedure #:clean #:enforce)
chicken.posix#group-information (fixnum #!optional *) *))
-(chicken.posix#initialize-groups (#(procedure #:clean #:enforce)
chicken.posix#initialize-groups (string fixnum) undefined))
(chicken.posix#local-time->seconds (#(procedure #:clean #:enforce)
chicken.posix#local-time->seconds ((vector fixnum fixnum fixnum fixnum fixnum
fixnum fixnum fixnum boolean fixnum)) integer))
(chicken.posix#local-timezone-abbreviation (#(procedure #:clean)
chicken.posix#local-timezone-abbreviation () string))
(chicken.posix#open-input-file* (#(procedure #:clean #:enforce)
chicken.posix#open-input-file* (fixnum #!optional symbol) input-port))
@@ -2026,7 +2023,6 @@
(chicken.posix#set-alarm! (#(procedure #:clean #:enforce)
chicken.posix#set-alarm! (integer) integer))
(chicken.posix#set-buffering-mode! (#(procedure #:clean #:enforce)
chicken.posix#set-buffering-mode! (port symbol #!optional fixnum) undefined))
(chicken.posix#set-file-position! (#(procedure #:clean #:enforce)
chicken.posix#set-file-position! ((or port fixnum) integer #!optional fixnum)
undefined))
-(chicken.posix#set-groups! (#(procedure #:clean #:enforce)
chicken.posix#set-groups! ((list-of fixnum)) undefined))
(chicken.posix#set-root-directory! (#(procedure #:clean #:enforce)
chicken.posix#set-root-directory! (string) undefined))
(chicken.posix#set-signal-handler! (#(procedure #:clean #:enforce)
chicken.posix#set-signal-handler! (fixnum (or false (procedure (fixnum) . *)))
undefined))
(chicken.posix#set-signal-mask! (#(procedure #:clean #:enforce)
chicken.posix#set-signal-mask! ((list-of fixnum)) undefined))
--
2.8.1