aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Woodward2007-10-06 04:12:10 +0000
committerJason Woodward2007-10-06 04:12:10 +0000
commitbef14bf9bdaf22e06a64b41bb06b107f1e4f4914 (patch)
tree0e41c008e456c82ef040d239c0955b501a5f9922 /src
parentb3aa1bb2a24ed470b76c4fc8df29301763747a44 (diff)
downloadslapt-get-bef14bf9bdaf22e06a64b41bb06b107f1e4f4914.tar.gz
Allow any option with --simulate to be ran without write privileges to the working directory. Allow --version to be ran without write privileges to the working directory.
Diffstat (limited to 'src')
-rw-r--r--src/configuration.c7
-rw-r--r--src/main.c10
2 files changed, 13 insertions, 4 deletions
diff --git a/src/configuration.c b/src/configuration.c
index 2957930..dd81801 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -124,6 +124,7 @@ slapt_rc_config *slapt_read_rc_config(const char *file_name)
void slapt_working_dir_init(const slapt_rc_config *global_config)
{
DIR *working_dir;
+ int mode = W_OK;
if ( (working_dir = opendir(global_config->working_dir)) == NULL ) {
if ( mkdir(global_config->working_dir,
@@ -140,7 +141,11 @@ void slapt_working_dir_init(const slapt_rc_config *global_config)
}
closedir(working_dir);
- if ( access(global_config->working_dir,W_OK) == -1 ) {
+ /* allow read access if we are simulating */
+ if (global_config->simulate)
+ mode = R_OK;
+
+ if ( access(global_config->working_dir,mode) == -1 ) {
if ( errno )
perror(global_config->working_dir);
diff --git a/src/main.c b/src/main.c
index b1ed35f..3538507 100644
--- a/src/main.c
+++ b/src/main.c
@@ -253,6 +253,13 @@ int main( int argc, char *argv[] )
exit(EXIT_FAILURE);
}
+ if ( do_action == SHOWVERSION ) {
+ version_info();
+ slapt_free_rc_config(global_config);
+ curl_global_cleanup();
+ exit(EXIT_SUCCESS);
+ }
+
/* create the working directory if needed */
slapt_working_dir_init(global_config);
chdir(global_config->working_dir);
@@ -347,9 +354,6 @@ int main( int argc, char *argv[] )
slapt_clean_pkg_dir(global_config->working_dir);
chdir(global_config->working_dir);
break;
- case SHOWVERSION:
- version_info();
- break;
case AUTOCLEAN:
slapt_purge_old_cached_pkgs(global_config, NULL, NULL);
break;