@@ -144,7 +144,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
144144 fd = open (file , O_CREAT | O_TRUNC | O_WRONLY , 0600 );
145145 if (-1 == fd ) {
146146 if (log ) {
147- (void ) fprintf (stderr ,
147+ (void ) fprintf (shadow_logfd ,
148148 "%s: %s: %s\n" ,
149149 Prog , file , strerror (errno ));
150150 }
@@ -156,7 +156,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
156156 len = (ssize_t ) strlen (buf ) + 1 ;
157157 if (write (fd , buf , (size_t ) len ) != len ) {
158158 if (log ) {
159- (void ) fprintf (stderr ,
159+ (void ) fprintf (shadow_logfd ,
160160 "%s: %s file write error: %s\n" ,
161161 Prog , file , strerror (errno ));
162162 }
@@ -166,7 +166,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
166166 }
167167 if (fdatasync (fd ) == -1 ) {
168168 if (log ) {
169- (void ) fprintf (stderr ,
169+ (void ) fprintf (shadow_logfd ,
170170 "%s: %s file sync error: %s\n" ,
171171 Prog , file , strerror (errno ));
172172 }
@@ -179,7 +179,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
179179 if (link (file , lock ) == 0 ) {
180180 retval = check_link_count (file );
181181 if ((0 == retval ) && log ) {
182- (void ) fprintf (stderr ,
182+ (void ) fprintf (shadow_logfd ,
183183 "%s: %s: lock file already used\n" ,
184184 Prog , file );
185185 }
@@ -190,7 +190,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
190190 fd = open (lock , O_RDWR );
191191 if (-1 == fd ) {
192192 if (log ) {
193- (void ) fprintf (stderr ,
193+ (void ) fprintf (shadow_logfd ,
194194 "%s: %s: %s\n" ,
195195 Prog , lock , strerror (errno ));
196196 }
@@ -202,7 +202,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
202202 close (fd );
203203 if (len <= 0 ) {
204204 if (log ) {
205- (void ) fprintf (stderr ,
205+ (void ) fprintf (shadow_logfd ,
206206 "%s: existing lock file %s without a PID\n" ,
207207 Prog , lock );
208208 }
@@ -213,7 +213,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
213213 buf [len ] = '\0' ;
214214 if (get_pid (buf , & pid ) == 0 ) {
215215 if (log ) {
216- (void ) fprintf (stderr ,
216+ (void ) fprintf (shadow_logfd ,
217217 "%s: existing lock file %s with an invalid PID '%s'\n" ,
218218 Prog , lock , buf );
219219 }
@@ -223,7 +223,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
223223 }
224224 if (kill (pid , 0 ) == 0 ) {
225225 if (log ) {
226- (void ) fprintf (stderr ,
226+ (void ) fprintf (shadow_logfd ,
227227 "%s: lock %s already used by PID %lu\n" ,
228228 Prog , lock , (unsigned long ) pid );
229229 }
@@ -233,7 +233,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
233233 }
234234 if (unlink (lock ) != 0 ) {
235235 if (log ) {
236- (void ) fprintf (stderr ,
236+ (void ) fprintf (shadow_logfd ,
237237 "%s: cannot get lock %s: %s\n" ,
238238 Prog , lock , strerror (errno ));
239239 }
@@ -245,13 +245,13 @@ static int do_lock_file (const char *file, const char *lock, bool log)
245245 if (link (file , lock ) == 0 ) {
246246 retval = check_link_count (file );
247247 if ((0 == retval ) && log ) {
248- (void ) fprintf (stderr ,
248+ (void ) fprintf (shadow_logfd ,
249249 "%s: %s: lock file already used\n" ,
250250 Prog , file );
251251 }
252252 } else {
253253 if (log ) {
254- (void ) fprintf (stderr ,
254+ (void ) fprintf (shadow_logfd ,
255255 "%s: cannot get lock %s: %s\n" ,
256256 Prog , lock , strerror (errno ));
257257 }
@@ -442,7 +442,7 @@ int commonio_lock (struct commonio_db *db)
442442 if (0 == lock_count ) {
443443 if (lckpwdf () == -1 ) {
444444 if (geteuid () != 0 ) {
445- (void ) fprintf (stderr ,
445+ (void ) fprintf (shadow_logfd ,
446446 "%s: Permission denied.\n" ,
447447 Prog );
448448 }
@@ -478,7 +478,7 @@ int commonio_lock (struct commonio_db *db)
478478 }
479479 /* no unnecessary retries on "permission denied" errors */
480480 if (geteuid () != 0 ) {
481- (void ) fprintf (stderr , "%s: Permission denied.\n" ,
481+ (void ) fprintf (shadow_logfd , "%s: Permission denied.\n" ,
482482 Prog );
483483 return 0 ;
484484 }
@@ -1109,7 +1109,7 @@ int commonio_update (struct commonio_db *db, const void *eptr)
11091109 p = find_entry_by_name (db , db -> ops -> getname (eptr ));
11101110 if (NULL != p ) {
11111111 if (next_entry_by_name (db , p -> next , db -> ops -> getname (eptr )) != NULL ) {
1112- fprintf (stderr , _ ("Multiple entries named '%s' in %s. Please fix this with pwck or grpck.\n" ), db -> ops -> getname (eptr ), db -> filename );
1112+ fprintf (shadow_logfd , _ ("Multiple entries named '%s' in %s. Please fix this with pwck or grpck.\n" ), db -> ops -> getname (eptr ), db -> filename );
11131113 db -> ops -> free (nentry );
11141114 return 0 ;
11151115 }
@@ -1214,7 +1214,7 @@ int commonio_remove (struct commonio_db *db, const char *name)
12141214 return 0 ;
12151215 }
12161216 if (next_entry_by_name (db , p -> next , name ) != NULL ) {
1217- fprintf (stderr , _ ("Multiple entries named '%s' in %s. Please fix this with pwck or grpck.\n" ), name , db -> filename );
1217+ fprintf (shadow_logfd , _ ("Multiple entries named '%s' in %s. Please fix this with pwck or grpck.\n" ), name , db -> filename );
12181218 return 0 ;
12191219 }
12201220
0 commit comments