OSDN Git Service

2ed7cc08fccffd27ab6e19e50670dae7684dd037
[linuxjm/LDP_man-pages.git] / release / man3 / getenv.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright (C) 2007, 2012 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\" References consulted:
27 .\"     Linux libc source code
28 .\"     Lewine's "POSIX Programmer's Guide" (O'Reilly & Associates, 1991)
29 .\"     386BSD man pages
30 .\" Modified Sat Jul 24 19:30:29 1993 by Rik Faith (faith@cs.unc.edu)
31 .\" Modified Fri Feb 14 21:47:50 1997 by Andries Brouwer (aeb@cwi.nl)
32 .\"
33 .\"*******************************************************************
34 .\"
35 .\" This file was generated with po4a. Translate the source file.
36 .\"
37 .\"*******************************************************************
38 .\"
39 .\" Japanese Version Copyright (c) 1997 Taro Morioka
40 .\"         all rights reserved.
41 .\" Translated Tue 08 04 06:00:00 JST 1997
42 .\"         by Tarho Morioka (t-morioka@nri.co.jp)
43 .\" Modified 2003-09-27 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
44 .\" Updated 2008-08-07, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.05
45 .\" Updated 2013-05-07, Akihiro MOTOKI <amotoki@gmail.com>
46 .\"
47 .TH GETENV 3 2012\-08\-14 GNU "Linux Programmer's Manual"
48 .SH 名前
49 getenv, secure_getenv \- 環境変数を得る
50 .SH 書式
51 .nf
52 \fB#include <stdlib.h>\fP
53 .sp
54 \fBchar *getenv(const char *\fP\fIname\fP\fB);\fP
55
56 \fBchar *secure_getenv(const char *\fP\fIname\fP\fB);\fP
57 .fi
58 .sp
59 .in -4n
60 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
61 .in
62 .sp
63 \fBsecure_getenv\fP(): _GNU_SOURCE
64 .SH 説明
65 関数 \fBgetenv\fP()  は、環境リストから名前が \fIname\fP の環境変数を検索し、対応する \fIvalue\fP 文字列へのポインタを返す。
66
67 GNU 固有の \fBsecure_getenv\fP() 関数は \fBgetenv\fP() と同様だが、 "secure execution"
68 (「安全な実行」) が必要な場合には NULL を返す点が異なる。 "secure execution" が必要となるのは、
69 呼び出し元プロセスにより実行されるプログラムがロードされる際に、 以下の条件のいずれか一つが成立する場合である。
70 .IP * 3
71 プロセスの実効ユーザ ID がプロセスの実ユーザ ID と一致しない場合、またはプロセスの実効グループ ID がプロセスの実グループ ID
72 と一致しない場合 (通常、この状況になるのは、 set\-user\-ID プログラムか set\-group\-ID プログラムを実行した場合である)。
73 .IP *
74 実行ファイルで実効ケーパビリティビットがセットされている場合。
75 .IP *
76 プロセスの許可ケーパビリティセットが空でない場合。
77 .PP
78 Linux セキュリティモジュールにより要求された場合にも "secure execution" は必要となる。
79
80 \fBsecure_getenv\fP() 関数は、 set\-user\-ID プログラムや set\-group\-ID
81 プログラムが実行環境を偶然信用してしまった場合に起こり得る脆弱性を、 汎用ライブラリで回避するために使うことを意図して作られた。
82 .SH 返り値
83 関数 \fBgetenv\fP()  は、環境における値 value へのポインタを返す。 \fIname\fP にマッチする環境変数が存在しないときには NULL
84 を返す。
85 .SH バージョン
86 \fBsecure_getenv\fP() は glibc 2.17 で初めて登場した。
87 .SH 準拠
88 \fBgetenv\fP(): SVr4, POSIX.1\-2001, 4.3BSD, C89, C99.
89
90 \fBsecure_getenv\fP() は GNU による拡張である。
91 .SH 注意
92 環境リストの文字列は \fIname=value\fP という形式をしている。
93
94 通常の実装では、 \fBgetenv\fP()  は環境リスト内の文字列へのポインタを返す。 呼び出し元はこの文字列を変更しないように注意しなければならない。
95 この文字列を変更すると、そのプロセスの環境を変化させることになるからである。
96
97 \fBgetenv\fP()  の実装はリエントラント (再入可能) であることを要求されていない。 \fBgetenv\fP()
98 の返り値により参照される文字列は静的に割り当てられてもよく、 文字列の内容は後続の \fBgetenv\fP(), \fBputenv\fP(3),
99 \fBsetenv\fP(3), \fBunsetenv\fP(3)  の呼び出しにより変更されることがある。
100
101 \fBsecure_getenv\fP() の "secure execution" モードは、 カーネルからユーザ空間に渡される補助ベクトル
102 (auxiliary vector) の \fBAT_SECURE\fP フラグにより制御される。
103 .SH 関連項目
104 \fBclearenv\fP(3), \fBgetauxval\fP(3), \fBputenv\fP(3), \fBsetenv\fP(3), \fBunsetenv\fP(3),
105 \fBcapabilities\fP(7), \fBenviron\fP(7)
106 .SH この文書について
107 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.65 の一部
108 である。プロジェクトの説明とバグ報告に関する情報は
109 http://www.kernel.org/doc/man\-pages/ に書かれている。