/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to plugins.d/mandos-client.c

* plugins.d/mandos-client.c (main): Use remove() instead of unlink(),
                                    and use it on everything in the
                                    temporary directory, not just
                                    files.

* plugins.d/mandos-client.xml (DESCRIPTION): Better wording.
  (OPTIONS): For the "--interface" option, document the unsuitability
             of pseudo-interfaces which will not exist in the initrd.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#define _GNU_SOURCE             /* TEMP_FAILURE_RETRY(), asprintf() */
37
37
 
38
38
#include <stdio.h>              /* fprintf(), stderr, fwrite(),
39
 
                                   stdout, ferror(), sscanf */
 
39
                                   stdout, ferror(), sscanf(),
 
40
                                   remove() */
40
41
#include <stdint.h>             /* uint16_t, uint32_t */
41
42
#include <stddef.h>             /* NULL, size_t, ssize_t */
42
43
#include <stdlib.h>             /* free(), EXIT_SUCCESS, EXIT_FAILURE,
1130
1131
          if(direntry == NULL){
1131
1132
            break;
1132
1133
          }
1133
 
          if(direntry->d_type == DT_REG){
1134
 
            char *fullname = NULL;
1135
 
            ret = asprintf(&fullname, "%s/%s", tempdir,
1136
 
                           direntry->d_name);
1137
 
            if(ret < 0){
1138
 
              perror("asprintf");
1139
 
              continue;
1140
 
            }
1141
 
            ret = unlink(fullname);
1142
 
            if(ret == -1){
1143
 
              fprintf(stderr, "unlink(\"%s\"): %s",
1144
 
                      fullname, strerror(errno));
1145
 
            }
1146
 
            free(fullname);
1147
 
          }
 
1134
          /* Skip "." and ".." */
 
1135
          if(direntry->d_name[0] == '.'
 
1136
             and (direntry->d_name[1] == '\0'
 
1137
                  or (direntry->d_name[1] == '.'
 
1138
                      and direntry->d_name[2] == '\0'))){
 
1139
            continue;
 
1140
          }
 
1141
          char *fullname = NULL;
 
1142
          ret = asprintf(&fullname, "%s/%s", tempdir,
 
1143
                         direntry->d_name);
 
1144
          if(ret < 0){
 
1145
            perror("asprintf");
 
1146
            continue;
 
1147
          }
 
1148
          ret = remove(fullname);
 
1149
          if(ret == -1){
 
1150
            fprintf(stderr, "remove(\"%s\"): %s\n", fullname,
 
1151
                    strerror(errno));
 
1152
          }
 
1153
          free(fullname);
1148
1154
        }
1149
1155
        closedir(d);
1150
1156
      }
1153
1159
        perror("rmdir");
1154
1160
      }
1155
1161
    }
1156
 
          
 
1162
    
1157
1163
    return exitcode;
1158
1164
}