setnetgrentのヘルプ・マニュアル
日本語 英語
setnetgrent --help
man setnetgrent
SETNETGRENT(3) Linux Programmer’s Manual SETNETGRENT(3)
名前
setnetgrent, endnetgrent, getnetgrent, getnetgrent_r, innetgr - ネット
ワーク・グループのエントリを操作する
書式
#include
int setnetgrent(const char *netgroup);
void endnetgrent(void);
int getnetgrent(char **host, char **user, char **domain);
int getnetgrent_r(char **host, char **user,
char **domain, char *buf, int buflen);
int innetgr(const char *netgroup, const char *host,
const char *user, const char *domain);
glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):
setnetgrent(), endnetgrent(), getnetgrent(), getnetgrent_r(),
innetgr(): _BSD_SOURCE || _SVID_SOURCE
説明
netgroup は SunOS で考案されたものである。ネットグループのデータベース
のエントリは、 3 つの文字列のリスト (hostname, username, domainname) も
し くはネットグループ名である。前記のリストの各要素は空であってもよい。
空は何とでも一致することを意味する。本ページで説明する関数を使うこと で
、 ネットグループのデータベースにアクセスすることができる。どのデータベ
ースが検索されるかは /etc/nsswitch.conf ファイルで定義されている。
setnetgrent() コールは、この後で呼ばれる getnetgrent() コールが検索する
ネットグループを定める。 getnetgrent() 関数はネットグループの次のエント
リを取得し、 host, user, domain にポインタを入れて返る。 NULL ポイン タ
は 、対応するエントリがどんな文字列とも一致することを意味する。得られた
ポインタは、ネットグループ関係の関数のいずれかが呼ばれるまでの間だけ 有
効 である。この問題を避けるためには GNU 拡張の関数 getnetgrent_r() を使
うとよい。この関数は呼び出し側が用意したバッファに文字列を格納する。 割
り当て済のバッファを全て解放するには endnetgrent() を使用する。
ほとんどの場合、 (hostname, username, domainname) の3要素の組がネットグ
ループのメンバーかどうかを確認したいだけであろう。 innetgr() 関数を使う
と、上記の3つの関数を呼び出さずにこの目的を達成できる。もう一度書いてお
くが、NULL ポインタはワイルドカードであり、あらゆる文字列と一致する。こ
の関数はスレッドセーフである。
返り値
これらの関数は成功すると 1 を、失敗すると 0 を返す。
ファイル
/etc/netgroup
/etc/nsswitch.conf
準拠
こ れ ら の関数は POSIX.1-2001 にはないが、 setnetgrent (), endnetgrent
(), getnetgrent (), innetgr () はほとんどの Unix システムで利用可能であ
る。 getnetgrent_r() は広く他のシステムで利用できるわけではない。
注意
BSD の実装では setnetgrent() は void を返す。
関連項目
sethostent(3), setprotoent(3), setservent(3)
GNU 2007-07-26 SETNETGRENT(3)
SETNETGRENT(3) Linux Programmer’s Manual SETNETGRENT(3)
NAME
setnetgrent, endnetgrent, getnetgrent, getnetgrent_r, innetgr - handle
network group entries
SYNOPSIS
#include
int setnetgrent(const char *netgroup);
void endnetgrent(void);
int getnetgrent(char **host, char **user, char **domain);
int getnetgrent_r(char **host, char **user,
char **domain, char *buf, int buflen);
int innetgr(const char *netgroup, const char *host,
const char *user, const char *domain);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
setnetgrent(), endnetgrent(), getnetgrent(), getnetgrent_r(),
innetgr(): _BSD_SOURCE || _SVID_SOURCE
DESCRIPTION
The netgroup is a SunOS invention. A netgroup database is a list of
string triples (hostname, username, domainname) or other netgroup
names. Any of the elements in a triple can be empty, which means that
anything matches. The functions described here allow access to the
netgroup databases. The file /etc/nsswitch.conf defines what database
is searched.
The setnetgrent() call defines the netgroup that will be searched by
subsequent getnetgrent() calls. The getnetgrent() function retrieves
the next netgroup entry, and returns pointers in host, user, domain. A
NULL pointer means that the corresponding entry matches any string.
The pointers are valid only as long as there is no call to other net-
group-related functions. To avoid this problem you can use the GNU
function getnetgrent_r() that stores the strings in the supplied
buffer. To free all allocated buffers use endnetgrent().
In most cases you only want to check if the triplet (hostname, user-
name, domainname) is a member of a netgroup. The function innetgr()
can be used for this without calling the above three functions. Again,
a NULL pointer is a wildcard and matches any string. The function is
thread-safe.
RETURN VALUE
These functions return 1 on success and 0 for failure.
FILES
/etc/netgroup
/etc/nsswitch.conf
CONFORMING TO
These functions are not in POSIX.1-2001, but setnetgrent(), endnet-
grent(), getnetgrent(), and innetgr() are available on most Unix sys-
tems. getnetgrent_r() is not widely available on other systems.
NOTES
In the BSD implementation, setnetgrent() returns void.
SEE ALSO
sethostent(3), setprotoent(3), setservent(3)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
GNU 2007-07-26 SETNETGRENT(3)