Changeset 415 for trunk/src/sh_audit.c
- Timestamp:
- Nov 1, 2012, 7:45:54 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_audit.c
r373 r415 211 211 if (p >= 0) 212 212 { 213 char c ommand[64];214 215 sl_snprintf(c ommand, sizeof(command), _("%s -D -k samhain"),213 char ctl[64]; 214 215 sl_snprintf(ctl, sizeof(ctl), _("%s -D -k samhain"), 216 216 _(actl_paths[p])); 217 217 sh_error_handle (SH_ERR_ALL, FIL__, __LINE__, … … 219 219 _("Deleting audit daemon rules with key samhain"), 220 220 _("sh_audit_delete_all") ); 221 sh_ext_system(command); 222 } 223 return; 224 } 225 226 void sh_audit_mark (const char * file) 221 222 sl_strlcpy(ctl, _(actl_paths[p]), sizeof(ctl)); 223 sh_ext_system(ctl, ctl, "-D", "-k", _("samhain"), NULL); 224 } 225 return; 226 } 227 228 static void sh_audit_mark_int (const char * file) 227 229 { 228 230 static int flushRules = 0; … … 243 245 char * command = SH_ALLOC(len); 244 246 char * safe; 247 char ctl[64]; 245 248 246 249 sl_snprintf(command, len, _("%s -w %s -p wa -k samhain"), … … 255 258 SH_FREE(safe); 256 259 257 sh_ext_system(command); 258 } 259 return; 260 } 261 260 sl_strlcpy(ctl, _(actl_paths[p]), sizeof(ctl)); 261 sl_strlcpy(command, file, len); 262 263 sh_ext_system(ctl, ctl, "-w", command, "-p", "wa", "-k", _("samhain"), NULL); 264 265 SH_FREE(command); 266 } 267 return; 268 } 269 270 struct aud_list { 271 char * file; 272 struct aud_list * next; 273 }; 274 275 struct aud_list * mark_these = NULL; 276 277 static void add_this (char * file) 278 { 279 struct aud_list * this = SH_ALLOC(sizeof(struct aud_list)); 280 this->file = sh_utils_strdup(file); 281 this->next = mark_these; 282 return; 283 } 284 285 static int test_exchange (struct aud_list * this, char * file) 286 { 287 size_t len0 = sl_strlen(this->file); 288 size_t len1 = sl_strlen(file); 289 int ret = -1; 290 291 if (len0 == len1) 292 { 293 return strcmp(this->file, file); 294 } 295 else 296 { 297 char * s0 = SH_ALLOC(len0 + 2); 298 char * s1 = SH_ALLOC(len1 + 2); 299 300 sl_strlcpy(s0, this->file, len0 + 2); 301 sl_strlcpy(s1, file, len1 + 2); 302 303 if (s0 < s1) 304 { 305 sl_strlcat(s0, "/", len0 + 2); 306 ret = strncmp(s0, s1, len0 + 1); 307 } 308 else 309 { 310 sl_strlcat(s1, "/", len1 + 2); 311 if (0 == strncmp(s0, s1, len1 + 1)) 312 { 313 SH_FREE(this->file); 314 this->file = sh_utils_strdup(file); 315 ret = 0; 316 } 317 } 318 SH_FREE(s0); 319 SH_FREE(s1); 320 } 321 322 return ret; 323 } 324 325 void sh_audit_mark (char * file) 326 { 327 struct aud_list * all = mark_these; 328 struct aud_list * this = mark_these; 329 330 if (!mark_these) { 331 add_this (file); 332 return; 333 } 334 335 while (this) 336 { 337 if (0 == test_exchange(this, file)) 338 return; 339 this = this->next; 340 } 341 342 add_this (file); 343 return; 344 } 345 346 void sh_audit_commit () 347 { 348 struct aud_list * next; 349 struct aud_list * this = mark_these; 350 351 mark_these = NULL; 352 353 while (this) 354 { 355 sh_audit_mark_int (this->file); 356 next = this->next; 357 SH_FREE(this->file); 358 SH_FREE(this); 359 this = next; 360 } 361 362 } 262 363 263 364 static int sh_audit_checkdaemon() … … 381 482 return; 382 483 } 484 void sh_audit_commit () 485 { 486 return; 487 } 383 488 #endif 384 489
Note:
See TracChangeset
for help on using the changeset viewer.