diff --git a/src/defaults.h b/src/defaults.h index efc0e71..41f7459 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -22,91 +22,102 @@ #define DAV_DEFAULTS_H -/* Misc. */ -/*=======*/ +/* Miscellaneous */ +/* ============= */ + +/* These Macros will be defined by the command line option -D of the + preprocessor: + + The name of the program. + DPROGRAM_NAME + + The directory to store the PID-file. + DAV_SYS_RUN + + The directory for translated messages (gettext). + LOCALEDIR +*/ + + +/* Configuration */ +/* ============= */ + +/* These Macros will be defined by the command line option -D of the + preprocessor: + + The directory where the system wide configuration file is located. + DAV_SYS_CONF_DIR + + The name of the configuration file. + DAV_CONFIG + + The directory where the template of the configuration file is located. + DAV_DATA_DIR + +*/ + + +/* Persona of the process */ +/* ====================== */ + +/* These Macros will be defined by the command line option -D of the + preprocessor: + + The program will run as this user if invoked by root. + May be overridden by system config file. + DAV_USER + + The program will belong to this group. + May be overridden by system config file. + DAV_GROUP +*/ + + +/* Mounting */ +/* ======== */ /* File system type to be used with 'mount -t' and fstab. */ #define DAV_FS_TYPE "davfs" -/* Mount options set by mount program in case of mounting by an - ordinary user. */ -#define DAV_USER_MOPTS (MS_MGC_VAL | MS_NOSUID | MS_NOEXEC | MS_NODEV) - -/* This mount options will allways be set by davfs2. Different values from - command line and even fstab will be silently ignored. */ -#define DAV_MOPTS (MS_MGC_VAL | MS_NOSUID | MS_NODEV) - -/* By default add option "_netdev" to mtab entry. */ -#define DAV_NETDEV 1 - -/* XML namespace for the cache index file. */ -#define DAV_XML_NS "http://dav.sf.net/" - - -/* Directories and Files */ -/*=======================*/ - -/* The device directory. */ -#define DAV_DEV_DIR "/dev" - /* The file davfs reads mtab entries from. If not available it will use _PATH_MOUNTED. */ #define DAV_MOUNTS "/proc/mounts" -/* The directory where the cache files will be stored, when mounted by - a non root users; relative to DAV_USER_DIR. - May be overridden by user config file. */ -#define DAV_CACHE "cache" +/* The device directory. */ +#define DAV_DEV_DIR "/dev" -/* The name of index files. */ -#define DAV_INDEX "index" +/* By default add option "_netdev" to mtab entry. + May be overridden by command line or fstab. */ +#define DAV_NETDEV 1 -/* Name of the directory within the davfs2 filesystem that holds local - backup files. +/* This mount options will allways be set by davfs2. Different values from + command line and even fstab will be silently ignored. */ +#define DAV_MOPTS (MS_MGC_VAL | MS_NOSUID | MS_NODEV) + +/* Mount options set by mount program in case of mounting by an + ordinary user. + May be overridden by command line or fstab. */ +#define DAV_USER_MOPTS (MS_MGC_VAL | MS_NOSUID | MS_NOEXEC | MS_NODEV) + +/* Size of the buffer used for communication with the kernerl in KiB. May be overridden by system config file and user config file. */ -#define DAV_BACKUP_DIR "lost+found" - -/* Buffer size for reading the XML index files of persistent cache. */ -#define DAV_XML_BUF_SIZE 16 * 1024 +#define DAV_FUSE_BUF_SIZE 32 -/* Cache Optimization */ -/*====================*/ +/* File mode */ +/* ========= */ -/* Cache size in MiByte. - May be overridden by system config file and user config file. - (1 MiByte = 1,048,576 Byte; Mi = Mebi = Mega Binary according to IEC) */ -#define DAV_CACHE_SIZE 50 +/* Mode of directories. + May be overridden by command line or fstab. */ +#define DAV_DIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) -/* Size of the hash table to store nodes. Should be a power of 2. - May be overridden by system config file and user config file. */ -#define DAV_TABLE_SIZE 1024 - -/* How long in seconds a cached directory is valid. After this time - a new PROPFIND request for this directory must be performed. - May be overridden by system config file and user config file. */ -#define DAV_DIR_REFRESH 60 - -/* Wait at least that many seconds from last file access until a new - GET If-Modified request is send to the server. If set to 0 a request - will be send every time the file is opened. But some applications do - open and close calls in short sequence that cause - mostly - unnecessary - traffic. - May be overridden by system config file and user config file. */ -#define DAV_FILE_REFRESH 1 - -/* How long to delay uploading of locally changed files after closing. - May be overridden by system config file and user config file. */ -#define DAV_DELAY_UPLOAD 10 - -/* Use PROPFIND to get the Last-Modified time of all files in a directory - instead of GET If-Modified_Since for single files. - May be overridden by system config file and user config file. */ -#define DAV_GUI_OPTIMIZE 0 +/* Mode of regular files. + May be overridden by command line or fstab. */ +#define DAV_FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) -/* HTTP */ -/*======*/ +/* WebDAV */ +/* ====== */ /* The default proxy port. May be overridden by system config file, user config file or environment @@ -125,6 +136,14 @@ May be overridden by command line or fstab. */ #define DAV_LOCKS 1 +/* Preferred live time of locks in seconds, before they have to be refreshed. + May be overridden by system config file and user config file. */ +#define DAV_LOCK_TIMEOUT 1800 + +/* How many seconds before a lock expires it should be refreshed. + May be overridden by system config file and user config file. */ +#define DAV_LOCK_REFRESH 60 + /* Send expect 100-continue header in PUT requests. May be overridden by system config file and user config file. */ #define DAV_EXPECT100 0 @@ -178,13 +197,83 @@ May be overridden by system config file and user config file. */ #define DAV_MAX_UPLOAD_ATTEMPTS 15 -/* Preferred live time of locks in seconds, before they have to be refreshed. - May be overridden by system config file and user config file. */ -#define DAV_LOCK_TIMEOUT 1800 +/* These Macros will be defined by the command line option -D of the + preprocessor: -/* How many seconds before a lock expires it should be refreshed. + The name of the file that holds credentials to authenticate with the server. + May be overridden by user config file. + DAV_SECRETS + + The directory to store certificates. + May be overridden by system config file and user config file. + DAV_CERTS_DIR + + The directory to store client certificates. + May be overridden by system config file or user config file. + DAV_CLICERTS_DIR +*/ + + +/* Cache */ +/* =====*/ + +/* The name of index files. */ +#define DAV_INDEX "index" + +/* Buffer size for reading the XML index files of persistent cache. */ +#define DAV_XML_BUF_SIZE 16 * 1024 + +/* XML namespace for the cache index file. */ +#define DAV_XML_NS "http://dav.sf.net/" + +/* The directory where the cache files will be stored, when mounted by + a non root users; relative to DAV_USER_DIR. + May be overridden by user config file. */ +#define DAV_CACHE "cache" + +/* Name of the directory within the davfs2 filesystem that holds local + backup files. May be overridden by system config file and user config file. */ -#define DAV_LOCK_REFRESH 60 +#define DAV_BACKUP_DIR "lost+found" + +/* Cache size in MiByte. + May be overridden by system config file and user config file. + (1 MiByte = 1,048,576 Byte; Mi = Mebi = Mega Binary according to IEC) */ +#define DAV_CACHE_SIZE 50 + +/* Size of the hash table to store nodes. Should be a power of 2. + May be overridden by system config file and user config file. */ +#define DAV_TABLE_SIZE 1024 + +/* How long in seconds a cached directory is valid. After this time + a new PROPFIND request for this directory must be performed. + May be overridden by system config file and user config file. */ +#define DAV_DIR_REFRESH 60 + +/* Wait at least that many seconds from last file access until a new + GET If-Modified request is send to the server. If set to 0 a request + will be send every time the file is opened. But some applications do + open and close calls in short sequence that cause - mostly - unnecessary + traffic. + May be overridden by system config file and user config file. */ +#define DAV_FILE_REFRESH 1 + +/* How long to delay uploading of locally changed files after closing. + May be overridden by system config file and user config file. */ +#define DAV_DELAY_UPLOAD 10 + +/* Use PROPFIND to get the Last-Modified time of all files in a directory + instead of GET If-Modified_Since for single files. + May be overridden by system config file and user config file. */ +#define DAV_GUI_OPTIMIZE 0 + +/* These Macros will be defined by the command line option -D of the + preprocessor: + + The directory where cache files will be stored when mounted by root. + May be overridden by system config file. + DAV_SYS_CACHE +*/ /* Debug Constants */ diff --git a/src/mount_davfs.c b/src/mount_davfs.c index 0e95c6d..d430be2 100644 --- a/src/mount_davfs.c +++ b/src/mount_davfs.c @@ -1294,6 +1294,9 @@ delete_args(dav_args *args) { if (args->cmdline) free(args->cmdline); + if (args->conf) + free(args->conf); + if (args->uid_name) free(args->uid_name); if (args->groups) @@ -1304,10 +1307,9 @@ delete_args(dav_args *args) free(args->dav_user); if (args->dav_group) free(args->dav_group); - if (args->conf) - free(args->conf); if (args->add_mopts) free(args->add_mopts); + if (args->scheme) free(args->scheme); if (args->host) @@ -1360,6 +1362,7 @@ delete_args(dav_args *args) free(args->s_charset); if (args->header) free(args->header); + if (args->sys_cache) free(args->sys_cache); if (args->cache_dir) @@ -1615,7 +1618,7 @@ get_options(dav_args *args, char *option) /* Allocates a new dav_args-structure. Numerical values are initialized to the default values from defaults.h if they are defined there or to 0 otherwise. - mopts is set to DAV_USER_MOPTS. + mopts is set to DAV_MOPTS. String and array pointers are initialized to NULL. */ static dav_args * new_args(void) @@ -1624,15 +1627,20 @@ new_args(void) args->netdev = DAV_NETDEV; args->mopts = DAV_MOPTS; + args->buf_size = DAV_FUSE_BUF_SIZE; + +/* TODO: activate after changing default mode and rmoving + umask. Remove eval_mode. + args->dir_mode = DAV_DIR_MODE; + args->file_mode = DAV_FILE_MODE; +*/ args->p_port = DAV_DEFAULT_PROXY_PORT; args->useproxy = DAV_USE_PROXY; - - args->lock_timeout = DAV_LOCK_TIMEOUT; - args->lock_refresh = DAV_LOCK_REFRESH; - args->askauth = DAV_ASKAUTH; args->locks = DAV_LOCKS; + args->lock_timeout = DAV_LOCK_TIMEOUT; + args->lock_refresh = DAV_LOCK_REFRESH; args->expect100 = DAV_EXPECT100; args->if_match_bug = DAV_IF_MATCH_BUG; args->drop_weak_etags = DAV_DROP_WEAK_ETAGS; diff --git a/src/mount_davfs.h b/src/mount_davfs.h index 539d24b..57dc592 100644 --- a/src/mount_davfs.h +++ b/src/mount_davfs.h @@ -31,7 +31,9 @@ Some data will be copied into global or local variables to be available in daemon mode. The rest will be freed when forking into daemon mode. */ typedef struct { + /* Configuration */ char *cmdline; + char *conf; /* Command line */ /* Persona */ int privileged; uid_t uid; @@ -44,7 +46,6 @@ typedef struct { char *dav_group; /* System config file */ uid_t dav_uid; gid_t dav_gid; - char *conf; /* Command line */ /* Mount options */ int user; /* Command line */ int users; /* Command line */ @@ -59,7 +60,7 @@ typedef struct { mode_t file_umask; mode_t dir_mode; /* Command line */ mode_t file_mode; /* Command line */ - /* WebDAV-resource */ + /* WebDAV */ char *scheme; /* Command line */ char *host; /* Command line */ int port; /* Command line */