diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2012-12-31 20:08:30 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2012-12-31 20:08:30 +0100 |
| commit | 95b85be502f639fb2080ae92d4d33c013b18aa94 (patch) | |
| tree | 7ca15af789198da9021937269eda023946b69221 /src/job-manager.c | |
| parent | 571790ba31a48c108e42c4ae10f8e63ae734c376 (diff) | |
| download | cataract-95b85be502f639fb2080ae92d4d33c013b18aa94.tar.xz | |
Add support for password protected albums
This adds support for simple password protected areas (albums and
all subalbums) through webserver HTTP authentication. CGG simply
generates .htaccess and password files and it's up to the user to
set up the rest on server side.
No UI changes at this point. Limited to one user per album for
the moment.
Diffstat (limited to 'src/job-manager.c')
| -rw-r--r-- | src/job-manager.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/job-manager.c b/src/job-manager.c index bf3b0df..8044b7f 100644 --- a/src/job-manager.c +++ b/src/job-manager.c @@ -35,6 +35,7 @@ #define DEFAULT_DATA_DIR_MODE S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH +#define AUTH_PASSWD_FILE ".htpasswd" typedef struct { @@ -268,9 +269,34 @@ build_tree (TGallerySetup *setup, } } + /* Cleanup for auth */ + if (items->auth_type != AUTH_TYPE_NONE) { + /* We're appending by default to preserve user .htaccess file supplied as an extra file. + * Let's remove the target file to prevent endless appending when overwriting the dst structure. */ + s1 = g_build_filename (path_info->dest_dir, ".htaccess", NULL); + unlink (s1); + g_free (s1); + } + /* Copy extra files */ mirror_files (setup, items->extra_files, path_info->src_dir, path_info->dest_dir, " Copying extra files: "); + /* Write auth files */ + if (items->auth_type != AUTH_TYPE_NONE) { + if (setup->verbose) printf (" Writing auth files: "); + s1 = g_build_filename (path_info->dest_dir, AUTH_PASSWD_FILE, NULL); + if (write_auth_passwd_file (setup, s1, items) && setup->verbose) + printf ("%s ", AUTH_PASSWD_FILE); + g_free (s1); + s1 = g_build_filename (path_info->dest_dir, ".htaccess", NULL); + s2 = g_build_filename (setup->location_local_path, path_info->album_path, AUTH_PASSWD_FILE, NULL); + if (write_auth_htaccess_file (setup, s1, s2, items) && setup->verbose) + printf ("%s ", ".htaccess"); + g_free (s2); + g_free (s1); + if (setup->verbose) printf ("\n"); + } + /* Prepare target image directories */ for (l = g_list_first (setup->design->image_sizes); l; l = g_list_next (l)) { image_size = l->data; |
