diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2001-09-09 16:52:37 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2001-09-09 16:52:37 +0000 |
commit | 49eef6d5f7868a67b9ae84d747fb466d3335cf78 (patch) | |
tree | 6cb9f04cdfd2aaa8db8e2e5833211e4026305d66 /winsup/cygwin/passwd.cc | |
parent | d961def403a334176adb4c79cb02385bfca230e7 (diff) | |
download | cygnal-49eef6d5f7868a67b9ae84d747fb466d3335cf78.tar.gz cygnal-49eef6d5f7868a67b9ae84d747fb466d3335cf78.tar.bz2 cygnal-49eef6d5f7868a67b9ae84d747fb466d3335cf78.zip |
* cygheap.cc (init_cygheap::etc_changed): New method to signal
a change in /etc.
* cygheap.h (struct init_cygheap): Add member `etc_changed_h'
and method `etc_changed'.
* grp.cc (enum grp_state): Eliminate.
(class grp_check): Ditto.
(group_state): Define as `class pwdgrp_check'.
(parse_grp): Remeber path and modification time of /etc/group file.
* passwd.cc (enum_pwd_state): Eliminate.
(class pwd_check): Ditto.
(passwd_state): Define as `class pwdgrp_check'.
(read_etc_passwd): Remember path and modification time of /etc/passwd
file.
* pwdgrp.h: New file.
(enum pwdgrp_state): Substitutes `pwd_state' and `grp_state'.
(class pwdgrp_check): Substitutes `pwd_check' and `grp_check'.
Diffstat (limited to 'winsup/cygwin/passwd.cc')
-rw-r--r-- | winsup/cygwin/passwd.cc | 56 |
1 files changed, 4 insertions, 52 deletions
diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc index a43869676..f6943cda8 100644 --- a/winsup/cygwin/passwd.cc +++ b/winsup/cygwin/passwd.cc @@ -1,6 +1,6 @@ /* passwd.cc: getpwnam () and friends - Copyright 1996, 1997, 1998 Cygnus Solutions. + Copyright 1996, 1997, 1998, 2001 Cygnus Solutions. This file is part of Cygwin. @@ -23,6 +23,7 @@ details. */ #include "pinfo.h" #include "cygheap.h" #include <sys/termios.h> +#include "pwdgrp.h" /* Read /etc/passwd only once for better performance. This is done on the first call that needs information from it. */ @@ -31,57 +32,7 @@ static struct passwd *passwd_buf; /* passwd contents in memory */ static int curr_lines; static int max_lines; -/* Set to loaded when /etc/passwd has been read in by read_etc_passwd (). - Set to emulated if passwd is emulated. */ -/* Functions in this file need to check the value of passwd_state - and read in the password file if it isn't set. */ -enum pwd_state { - uninitialized = 0, - initializing, - emulated, - loaded -}; -class pwd_check { - pwd_state state; - FILETIME last_modified; - char pwd_w32[MAX_PATH]; - -public: - pwd_check () : state (uninitialized) - { - last_modified.dwLowDateTime = last_modified.dwHighDateTime = 0; - pwd_w32[0] = '\0'; - } - operator pwd_state () - { - HANDLE h; - WIN32_FIND_DATA data; - - if (!pwd_w32[0]) /* First call. */ - { - path_conv p ("/etc/passwd", PC_SYM_FOLLOW | PC_FULL); - if (!p.error) - strcpy (pwd_w32, p.get_win32 ()); - } - - if ((h = FindFirstFile (pwd_w32, &data)) != INVALID_HANDLE_VALUE) - { - if (CompareFileTime (&data.ftLastWriteTime, &last_modified) > 0) - { - state = uninitialized; - last_modified = data.ftLastWriteTime; - } - FindClose (h); - } - return state; - } - void operator = (pwd_state nstate) - { - state = nstate; - } -}; - -static pwd_check passwd_state; +static pwdgrp_check passwd_state; /* Position in the passwd cache */ @@ -200,6 +151,7 @@ read_etc_passwd () add_pwd_line (linebuf); } + passwd_state.set_last_modified (f); fclose (f); passwd_state = loaded; } |