From 49eef6d5f7868a67b9ae84d747fb466d3335cf78 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sun, 9 Sep 2001 16:52:37 +0000 Subject: * 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'. --- winsup/cygwin/cygheap.cc | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'winsup/cygwin/cygheap.cc') diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 53a66cfac..be52f0446 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -16,6 +16,7 @@ #include "security.h" #include "fhandler.h" #include "dtable.h" +#include "path.h" #include "cygheap.h" #include "child_info.h" #include "heap.h" @@ -345,6 +346,39 @@ cstrdup1 (const char *s) return p; } +bool +init_cygheap::etc_changed () +{ + bool res = 0; + + if (!etc_changed_h) + { + path_conv pwd ("/etc"); + etc_changed_h = FindFirstChangeNotification (pwd, FALSE, + FILE_NOTIFY_CHANGE_LAST_WRITE); + if (etc_changed_h == INVALID_HANDLE_VALUE) + system_printf ("Can't open /etc for checking, %E", (char *) pwd, + etc_changed_h); + else if (!DuplicateHandle (hMainProc, etc_changed_h, hMainProc, + &etc_changed_h, 0, TRUE, + DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE)) + { + system_printf ("Can't inherit /etc handle, %E", (char *) pwd, + etc_changed_h); + etc_changed_h = INVALID_HANDLE_VALUE; + } + } + + if (etc_changed_h != INVALID_HANDLE_VALUE + && WaitForSingleObject (etc_changed_h, 0) == WAIT_OBJECT_0) + { + (void) FindNextChangeNotification (etc_changed_h); + res = 1; + } + + return res; +} + void cygheap_root::set (const char *posix, const char *native) { -- cgit v1.2.3