Changeset 410 for trunk/src/sh_err_log.c
- Timestamp:
- Aug 28, 2012, 7:06:46 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_err_log.c
r405 r410 1058 1058 static char * gEfile = NULL; 1059 1059 static int gFail = 0; 1060 static long gGid = 0; 1061 1062 int sh_efile_group(const char * str) 1063 { 1064 int fail; 1065 long gid = sh_group_to_gid(str, &fail); 1066 1067 if (fail < 0) 1068 { 1069 return -1; 1070 } 1071 gGid = gid; 1072 return 0; 1073 } 1074 1060 1075 1061 1076 int sh_efile_path(const char * str) … … 1148 1163 fchmod (filed, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); 1149 1164 sl_close (fd); 1165 } 1166 else 1167 { 1168 static int nFail = 0; 1169 1170 if (nFail == 0) 1171 { 1172 char errmsg[1024]; 1173 char * tmp = sh_util_safe_name (lockfile); 1174 1175 sl_snprintf(errmsg, sizeof(errmsg), 1176 _("Error creating lockfile %s"), 1177 tmp); 1178 1179 sh_error_handle (SH_ERR_ERR, FIL__, __LINE__, 1180 0, MSG_E_SUBGEN, 1181 errmsg, _("sh_efile_lock")); 1182 ++nFail; 1183 SH_FREE(tmp); 1184 } 1150 1185 } 1151 1186 } … … 1191 1226 void sh_efile_report() 1192 1227 { 1228 extern int get_the_fd (SL_TICKET ticket); 1193 1229 SL_TICKET fd; 1194 1230 char *efile; … … 1226 1262 1227 1263 time_t now = time(NULL); 1264 int filed = get_the_fd(fd); 1228 1265 1229 1266 (void) sh_unix_time (now, tstamp, sizeof(tstamp)); … … 1233 1270 tstamp, 1234 1271 (long long) now, 1235 tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5]); 1272 (long) tmp[0], (long) tmp[1], (long) tmp[2], 1273 (long) tmp[3], (long) tmp[4], (long) tmp[5]); 1236 1274 #else 1237 1275 sl_snprintf(report, sizeof(report), … … 1239 1277 tstamp, 1240 1278 (long) now, 1241 tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5]); 1279 (long) tmp[0], (long) tmp[1], (long) tmp[2], 1280 (long) tmp[3], (long) tmp[4], (long) tmp[5]); 1242 1281 #endif 1243 1282 … … 1246 1285 status = sl_write (fd, report, strlen(report)); 1247 1286 (void) sl_sync(fd); 1287 1288 /* make group writeable, such that nagios can truncate */ 1289 fchmod (filed, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH); 1290 status = fchown (filed, -1, gGid); 1291 if (status < 0) 1292 { 1293 int errnum = errno; 1294 static int nFail = 0; 1295 if (nFail == 0) 1296 { 1297 char errmsg[1024]; 1298 char buf[256]; 1299 char * tmp = sh_util_safe_name (efile); 1300 1301 sl_snprintf(errmsg, sizeof(errmsg), 1302 _("Error changing group of %s to %ld: %s"), 1303 tmp, gGid, 1304 sh_error_message (errnum, buf, sizeof(buf))); 1305 sh_error_handle (SH_ERR_ERR, FIL__, __LINE__, 1306 errnum, MSG_E_SUBGEN, 1307 errmsg, _("sh_efile_report")); 1308 ++nFail; 1309 SH_FREE(tmp); 1310 } 1311 } 1312 1248 1313 (void) sl_close(fd); 1249 1314 }
Note:
See TracChangeset
for help on using the changeset viewer.