~vcs-imports/ipfire/ipfire-2.x

« back to all changes in this revision

Viewing changes to src/misc-progs/backupctrl.c

  • Committer: Daniel Glanzmann
  • Date: 2008-09-26 17:05:28 UTC
  • mto: (1394.1.12)
  • mto: This revision was merged to the branch mainline in revision 1401.
  • Revision ID: git-v1:19ac4d1b6e234e1391b3d406381e3b74e92c40dd
added new useragent thunderbird

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *
6
6
 */
7
7
 
 
8
#include <stdlib.h>
 
9
#include <stdio.h>
 
10
#include <string.h>
 
11
#include <unistd.h>
 
12
#include <sys/types.h>
 
13
#include <fcntl.h>
8
14
#include "setuid.h"
9
15
 
10
 
int main(int argc, char** argv) {
11
 
        if (!initsetuid())
 
16
int main(int argc, char *argv[]) {
 
17
        int i;
 
18
        char command[1024];
 
19
        char add[STRING_SIZE];
 
20
        
 
21
        if (!(initsetuid()))
12
22
                exit(1);
13
23
 
14
 
        return run("/var/ipfire/backup/bin/backup.pl", argv + 1);
 
24
        snprintf(command, STRING_SIZE, "/var/ipfire/backup/bin/backup.pl");
 
25
 
 
26
        for (i = 1; i < argc; i++) {
 
27
    if (strstr(argv[i], "&&")){
 
28
              fprintf (stderr, "Bad Argument!\n");
 
29
        exit (1);
 
30
    }
 
31
                else if (strstr(argv[i], "|")){
 
32
                    fprintf (stderr, "Bad Argument!\n");
 
33
                    exit (1);
 
34
                }
 
35
                else if (argc > 3){
 
36
                    fprintf (stderr, "Too Many Arguments!\n");
 
37
                    exit (1);
 
38
                }
 
39
                else{
 
40
                sprintf(add, " %s", argv[i]);
 
41
                    strcat(command, add);
 
42
    }
 
43
        }
 
44
        return safe_system(command);
15
45
}