projects
/
gapil.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Inserito un inizio di esempio dell'uso delle funzioni delle capabilities.
[gapil.git]
/
sources
/
mylschroot.c
diff --git
a/sources/mylschroot.c
b/sources/mylschroot.c
index 9d4d705af845483aa0cfbf06ef4b082c4d367f11..a2b2a8a18228d74965d4ff15c6da54cfe859b60e 100644
(file)
--- a/
sources/mylschroot.c
+++ b/
sources/mylschroot.c
@@
-45,6
+45,8
@@
int do_ls(struct dirent * direntry);
int main(int argc, char *argv[])
{
int i;
int main(int argc, char *argv[])
{
int i;
+ char * arg[]={"ls","-l", NULL};
+ struct stat data;
/*
* Input section: decode command line parameters
* Use getopt function
/*
* Input section: decode command line parameters
* Use getopt function
@@
-78,11
+80,22
@@
int main(int argc, char *argv[])
printf("Wrong number of arguments %d\n", argc - optind);
usage();
}
printf("Wrong number of arguments %d\n", argc - optind);
usage();
}
+
printf("Chrooting to %s\n", argv[1]);
if (chroot(argv[1])) {
perror("Chroot fail");
}
printf("Chrooting to %s\n", argv[1]);
if (chroot(argv[1])) {
perror("Chroot fail");
}
+
+ if (execve("/ls", arg, NULL)) {
+ perror("errore in execve");
+ }
+ if (stat("/ls", &data)) {
+ perror("errore in stat");
+ } else {
+ printf("inode: %d\n", data.st_ino);
+ }
DirScan("/", do_ls);
DirScan("/", do_ls);
+
exit(0);
}
/*
exit(0);
}
/*