Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2001-09-09 20:52:37 +0400
committerCorinna Vinschen <corinna@vinschen.de>2001-09-09 20:52:37 +0400
commit49eef6d5f7868a67b9ae84d747fb466d3335cf78 (patch)
tree6cb9f04cdfd2aaa8db8e2e5833211e4026305d66 /winsup/cygwin/grp.cc
parentd961def403a334176adb4c79cb02385bfca230e7 (diff)
* 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/grp.cc')
-rw-r--r--winsup/cygwin/grp.cc54
1 files changed, 3 insertions, 51 deletions
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index b70db13f8..3cac0fc1d 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -26,6 +26,7 @@ details. */
#include "path.h"
#include "cygheap.h"
#include "cygerrno.h"
+#include "pwdgrp.h"
/* Read /etc/group only once for better performance. This is done
on the first call that needs information from it. */
@@ -42,57 +43,7 @@ static int max_lines;
static int grp_pos = 0;
#endif
-/* 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 grp_state {
- uninitialized = 0,
- initializing,
- emulated,
- loaded
-};
-class grp_check {
- grp_state state;
- FILETIME last_modified;
- char grp_w32[MAX_PATH];
-
-public:
- grp_check () : state (uninitialized)
- {
- last_modified.dwLowDateTime = last_modified.dwHighDateTime = 0;
- grp_w32[0] = '\0';
- }
- operator grp_state ()
- {
- HANDLE h;
- WIN32_FIND_DATA data;
-
- if (!grp_w32[0]) /* First call. */
- {
- path_conv g ("/etc/group", PC_SYM_FOLLOW | PC_FULL);
- if (!g.error)
- strcpy (grp_w32, g.get_win32 ());
- }
-
- if ((h = FindFirstFile (grp_w32, &data)) != INVALID_HANDLE_VALUE)
- {
- if (CompareFileTime (&data.ftLastWriteTime, &last_modified) > 0)
- {
- state = uninitialized;
- last_modified = data.ftLastWriteTime;
- }
- FindClose (h);
- }
- return state;
- }
- void operator = (grp_state nstate)
- {
- state = nstate;
- }
-};
-
-static grp_check group_state;
+static pwdgrp_check group_state;
static int
parse_grp (struct group &grp, const char *line)
@@ -215,6 +166,7 @@ read_etc_group ()
add_grp_line (linebuf);
}
+ group_state.set_last_modified (f);
fclose (f);
group_state = loaded;
}