xbps-{bin,repo}: make sure that user has write permission on {root,meta,cache}dir.

Fixes issue #27
This commit is contained in:
Juan RP
2012-08-02 12:20:18 +02:00
parent cae219c4de
commit 3a247bd5cb
2 changed files with 33 additions and 0 deletions

View File

@@ -151,6 +151,20 @@ main(int argc, char **argv)
exit(EXIT_FAILURE);
}
/*
* Check that we have write permission on cachedir/metadir.
*/
if ((strcasecmp(argv[0], "sync") == 0) ||
(strcasecmp(argv[0], "clean") == 0)) {
if ((access(xh.metadir, W_OK) == -1) ||
(access(xh.cachedir, W_OK) == -1)) {
xbps_error_printf("xbps-repo: cannot write to "
"cachedir/metadir: %s\n", strerror(errno));
xbps_end(&xh);
exit(EXIT_FAILURE);
}
}
if (strcasecmp(argv[0], "list") == 0) {
/* Lists all repositories registered in pool. */
if (argc != 1)