Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 110 lines (90 sloc) 2.168 kb
da7cf36 @rwmjones Added 'scrub-*' commands for securely scrubbing filesystems.
rwmjones authored
1 /* libguestfs - the guestfsd daemon
a7b73d4 remove trailing blanks
Jim Meyering authored
2 * Copyright (C) 2009 Red Hat Inc.
da7cf36 @rwmjones Added 'scrub-*' commands for securely scrubbing filesystems.
rwmjones authored
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
04ea137 @mdbooth Update FSF address.
mdbooth authored
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
da7cf36 @rwmjones Added 'scrub-*' commands for securely scrubbing filesystems.
rwmjones authored
17 */
18
19 #include <config.h>
20
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <fcntl.h>
25 #include <unistd.h>
26
27 #include "daemon.h"
28 #include "actions.h"
2d99530 @rwmjones availability: Add optional groups and implement guestfs_available call.
rwmjones authored
29 #include "optgroups.h"
30
0306c98 @olafhering daemon: collect list of called external commands
olafhering authored
31 GUESTFSD_EXT_CMD(str_scrub, scrub);
32
2d99530 @rwmjones availability: Add optional groups and implement guestfs_available call.
rwmjones authored
33 int
34 optgroup_scrub_available (void)
35 {
0306c98 @olafhering daemon: collect list of called external commands
olafhering authored
36 return prog_exists (str_scrub);
2d99530 @rwmjones availability: Add optional groups and implement guestfs_available call.
rwmjones authored
37 }
da7cf36 @rwmjones Added 'scrub-*' commands for securely scrubbing filesystems.
rwmjones authored
38
39 int
84fc760 generator.ml: use new "Pathname" designation
Jim Meyering authored
40 do_scrub_device (const char *device)
da7cf36 @rwmjones Added 'scrub-*' commands for securely scrubbing filesystems.
rwmjones authored
41 {
42 char *err;
43 int r;
44
0306c98 @olafhering daemon: collect list of called external commands
olafhering authored
45 r = command (NULL, &err, str_scrub, device, NULL);
da7cf36 @rwmjones Added 'scrub-*' commands for securely scrubbing filesystems.
rwmjones authored
46 if (r == -1) {
e9c3711 @rwmjones daemon: Don't need to prefix error messages with the command name.
rwmjones authored
47 reply_with_error ("%s: %s", device, err);
da7cf36 @rwmjones Added 'scrub-*' commands for securely scrubbing filesystems.
rwmjones authored
48 free (err);
49 return -1;
50 }
51
52 free (err);
53
54 return 0;
55 }
56
57 int
84fc760 generator.ml: use new "Pathname" designation
Jim Meyering authored
58 do_scrub_file (const char *file)
da7cf36 @rwmjones Added 'scrub-*' commands for securely scrubbing filesystems.
rwmjones authored
59 {
60 char *buf;
61 char *err;
62 int r;
63
64 /* Make the path relative to /sysroot. */
78029b5 Make /sysroot path configurable.
Richard Jones authored
65 buf = sysroot_path (file);
da7cf36 @rwmjones Added 'scrub-*' commands for securely scrubbing filesystems.
rwmjones authored
66 if (!buf) {
67 reply_with_perror ("malloc");
68 return -1;
69 }
70
0306c98 @olafhering daemon: collect list of called external commands
olafhering authored
71 r = command (NULL, &err, str_scrub, "-r", buf, NULL);
da7cf36 @rwmjones Added 'scrub-*' commands for securely scrubbing filesystems.
rwmjones authored
72 free (buf);
73 if (r == -1) {
e9c3711 @rwmjones daemon: Don't need to prefix error messages with the command name.
rwmjones authored
74 reply_with_error ("%s: %s", file, err);
da7cf36 @rwmjones Added 'scrub-*' commands for securely scrubbing filesystems.
rwmjones authored
75 free (err);
76 return -1;
77 }
78
79 free (err);
80
81 return 0;
82 }
83
84 int
84fc760 generator.ml: use new "Pathname" designation
Jim Meyering authored
85 do_scrub_freespace (const char *dir)
da7cf36 @rwmjones Added 'scrub-*' commands for securely scrubbing filesystems.
rwmjones authored
86 {
87 char *buf;
88 char *err;
89 int r;
90
91 /* Make the path relative to /sysroot. */
78029b5 Make /sysroot path configurable.
Richard Jones authored
92 buf = sysroot_path (dir);
da7cf36 @rwmjones Added 'scrub-*' commands for securely scrubbing filesystems.
rwmjones authored
93 if (!buf) {
94 reply_with_perror ("malloc");
95 return -1;
96 }
97
0306c98 @olafhering daemon: collect list of called external commands
olafhering authored
98 r = command (NULL, &err, str_scrub, "-X", buf, NULL);
da7cf36 @rwmjones Added 'scrub-*' commands for securely scrubbing filesystems.
rwmjones authored
99 free (buf);
100 if (r == -1) {
e9c3711 @rwmjones daemon: Don't need to prefix error messages with the command name.
rwmjones authored
101 reply_with_error ("%s: %s", dir, err);
da7cf36 @rwmjones Added 'scrub-*' commands for securely scrubbing filesystems.
rwmjones authored
102 free (err);
103 return -1;
104 }
105
106 free (err);
107
108 return 0;
109 }
Something went wrong with that request. Please try again.