1 /* $NetBSD: safe_getenv.c,v 1.1.1.1 2009/06/23 10:09:00 tron Exp $ */ 2 3 /*++ 4 /* NAME 5 /* safe_getenv 3 6 /* SUMMARY 7 /* guarded getenv() 8 /* SYNOPSIS 9 /* #include <safe.h> 10 /* 11 /* char *safe_getenv(const name) 12 /* char *name; 13 /* DESCRIPTION 14 /* The \fBsafe_getenv\fR() routine reads the named variable from the 15 /* environment, provided that the unsafe() routine agrees. 16 /* SEE ALSO 17 /* unsafe(3), detect non-user privileges 18 /* LICENSE 19 /* .ad 20 /* .fi 21 /* The Secure Mailer license must be distributed with this software. 22 /* AUTHOR(S) 23 /* Wietse Venema 24 /* IBM T.J. Watson Research 25 /* P.O. Box 704 26 /* Yorktown Heights, NY 10598, USA 27 /*--*/ 28 29 /* System library. */ 30 31 #include <sys_defs.h> 32 #include <stdlib.h> 33 34 /* Utility library. */ 35 36 #include "safe.h" 37 38 /* safe_getenv - read environment variable with guard */ 39 40 char *safe_getenv(const char *name) 41 { 42 return (unsafe() == 0 ? getenv(name) : 0); 43 } 44