SETNETGRENT

Section: Linux Programmer's Manual (3)
Updated: 2017-09-15
Index JM Home Page
 

名前

setnetgrent, endnetgrent, getnetgrent, getnetgrent_r, innetgr - ネットワークグループのエントリーを操作する  

書式

#include <netdb.h>

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, size_t 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():
    glibc 2.19 以降:
        _DEFAULT_SOURCE
    glibc 2.19 以前:
        _BSD_SOURCE || _SVID_SOURCE  

説明

netgroup は SunOS で考案されたものである。ネットグループのデータベースの エントリーは、 3 つの文字列のリスト (hostname, username, domainname) もしくはネットグループ名である。 前記のリストの各要素は空であってもよい。 空は何とでも一致することを意味する。 本ページで説明する関数を使うことで、ネットグループのデータベースに アクセスすることができる。どのデータベースが検索されるかは /etc/nsswitch.conf ファイルで定義されている。

setnetgrent() コールは、この後で呼ばれる getnetgrent() コールが検索するネットグループを定める。 getnetgrent() 関数はネットグループの次のエントリーを取得し、 host, user, domain にポインターを入れて返る。ヌルポインターは、対応するエントリーがどんな文字列とも一致することを意味する。 得られたポインターは、ネットグループ関係の関数のいずれかが呼ばれるまでの 間だけ有効である。この問題を避けるためには GNU 拡張の関数 getnetgrent_r() を使うとよい。この関数は呼び出し側が用意したバッファーに 文字列を格納する。割り当て済のバッファーを全て解放するには endnetgrent() を使用する。

ほとんどの場合、 (hostname, username, domainname) の3要素の組がネットグループのメンバーかどうかを確認したいだけであろう。 innetgr() 関数を使うと、上記の3つの関数を呼び出さずにこの目的を達成できる。 もう一度書いておくが、NULL ポインターはワイルドカードであり、 あらゆる文字列と一致する。この関数はスレッドセーフである。  

返り値

これらの関数は成功すると 1 を、失敗すると 0 を返す。  

ファイル

/etc/netgroup
/etc/nsswitch.conf  

属性

この節で使用されている用語の説明は attributes(7) を参照のこと。
Interface Attribute Value
setnetgrent(),
getnetgrent_r(),
innetgr()
Thread safety MT-Unsafe race:netgrent
locale
endnetgrent() Thread safety MT-Unsafe race:netgrent
getnetgrent() Thread safety MT-Unsafe race:netgrent
race:netgrentbuf locale

In the above table, netgrent in race:netgrent signifies that if any of the functions setnetgrent(), getnetgrent_r(), innetgr(), getnetgrent(), or endnetgrent() are used in parallel in different threads of a program, then data races could occur.  

準拠

これらの関数は POSIX.1 にはないが、 setnetgrent (), endnetgrent (), getnetgrent (), innetgr () はほとんどの UNIX システムで利用可能である。 getnetgrent_r() は広く他のシステムで利用できるわけではない。  

注意

BSD の実装では setnetgrent() は void を返す。  

関連項目

sethostent(3), setprotoent(3), setservent(3)  

この文書について

この man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。

関連キーワード

getnetgrent, 関数, グループ, setnetgrent, endnetgrent, ネット, innetgr, SETNETGRENT, netgrent, エントリー

Linux マニュアル 一覧

[man1] [man2] [man3] [man4] [man5] [man6] [man7] [man8]
[a] [b] [c] [d] [e] [f] [g] [h] [i] [j] [k] [l] [m] [n] [o] [p] [q] [r] [s] [t] [u] [v] [w] [x] [y] [z]

 

Index

名前
書式
説明
返り値
ファイル
属性
準拠
注意
関連項目
この文書について

This document was created by man2html, using the manual pages.
Time: 12:08:36 GMT, June 11, 2022