/mandos/trunk

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

« back to all changes in this revision

Viewing changes to plugins.d/splashy.c

  • Committer: Teddy Hogeborn
  • Date: 2008-09-23 18:46:17 UTC
  • Revision ID: teddy@fukt.bsnet.se-20080923184617-r2rd8r7o2jvgz5ey
* Makefile (PLUGINS, uninstall-client,
            install-client-nokey): Added "plugins.d/splashy".

* plugin-runner.c: Change in comments.

* plugins.d/splashy: Removed; replaced by "splashy.c".
* plugins.d/splashy.c: New.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
  interrupted_by_signal = 1;
26
26
}
27
27
 
28
 
int main(__attribute__((unused))int argc,
29
 
         __attribute__((unused))char **argv){
 
28
int main(__attribute__((unused))int argc, char **argv){
30
29
  int ret = 0;
31
30
  
32
31
  /* Create prompt string */
77
76
      }
78
77
      /* Find the executable name by doing readlink() on the
79
78
         /proc/<pid>/exe link */
 
79
      char *exe_link;
 
80
      ret = asprintf(&exe_link, "/proc/%s/exe", proc_ent->d_name);
 
81
      if(ret == -1){
 
82
        perror("asprintf");
 
83
        free(prompt);
 
84
        closedir(proc_dir);
 
85
        return EXIT_FAILURE;
 
86
      }
80
87
      char exe_target[sizeof(splashy_name)];
81
 
      ssize_t sret;
82
 
      {
83
 
        char *exe_link;
84
 
        ret = asprintf(&exe_link, "/proc/%s/exe", proc_ent->d_name);
85
 
        if(ret == -1){
86
 
          perror("asprintf");
87
 
          free(prompt);
88
 
          closedir(proc_dir);
89
 
          return EXIT_FAILURE;
90
 
        }
91
 
        sret = readlink(exe_link, exe_target, sizeof(exe_target));
92
 
        free(exe_link);
93
 
      }
 
88
      ssize_t sret = readlink(exe_link, exe_target,
 
89
                              sizeof(exe_target));
94
90
      if((sret == ((ssize_t)sizeof(exe_target)-1))
95
91
         and (memcmp(splashy_name, exe_target,
96
92
                     sizeof(exe_target)-1) == 0)){
199
195
  if(interrupted_by_signal){
200
196
    kill(splashy_command_pid, SIGTERM);
201
197
  }
202
 
  
 
198
 
203
199
  pid_t new_splashy_pid = fork();
204
200
  if(new_splashy_pid == 0){
205
 
    /* Child; will become new splashy process */
206
201
    while(kill(splashy_pid, 0)){
207
202
      sleep(2);
208
203
      kill(splashy_pid, SIGKILL);