diff options
author | Badlop <badlop@process-one.net> | 2013-02-05 16:19:23 +0100 |
---|---|---|
committer | Badlop <badlop@process-one.net> | 2013-02-05 16:20:14 +0100 |
commit | 3f939314093eb707456a6c869ab5084b65c6ff1d (patch) | |
tree | 887b6c3dd85ca9a47fd2194550d0819137ccf9f5 | |
parent | Fix issue with ejabberd_xmlrpc user auth and SCRAM (diff) |
New mod_muc_log option file_permissions (EJAB-1588)
-rw-r--r-- | doc/guide.tex | 6 | ||||
-rw-r--r-- | src/mod_muc/mod_muc_log.erl | 15 |
2 files changed, 19 insertions, 2 deletions
diff --git a/doc/guide.tex b/doc/guide.tex index 35821d538..71f88ee82 100644 --- a/doc/guide.tex +++ b/doc/guide.tex @@ -3434,6 +3434,10 @@ Options: \term{html} stores in HTML format, \term{plaintext} stores in plain text. The default value is \term{html}. +\titem{\{file\_permissions, \{Mode, Group\}\}}\ind{options!file\_permissions} + Define the permissions that must be used when creating the log files: + the number of the mode, and the numeric id of the group that will own the files. + The default value is \term{\{644, 33\}}. \titem{\{outdir, Path\}}\ind{options!outdir} This option sets the full path to the directory in which the HTML files should be stored. Make sure the \ejabberd{} daemon user has write access on that @@ -3500,6 +3504,8 @@ Examples: {access_log, muc_log}, {cssfile, false}, {dirtype, subdirs}, + {dirtype, subdirs}, + {file_permissions, {644, 33}}, {outdir, "/var/www/muclogs"}, {timezone, local} ]}, diff --git a/src/mod_muc/mod_muc_log.erl b/src/mod_muc/mod_muc_log.erl index c6eb783e4..27f1340dc 100644 --- a/src/mod_muc/mod_muc_log.erl +++ b/src/mod_muc/mod_muc_log.erl @@ -60,6 +60,7 @@ dir_type, dir_name, file_format, + file_permissions, css_file, access, lang, @@ -123,6 +124,7 @@ init([Host, Opts]) -> DirType = gen_mod:get_opt(dirtype, Opts, subdirs), DirName = gen_mod:get_opt(dirname, Opts, room_jid), FileFormat = gen_mod:get_opt(file_format, Opts, html), % Allowed values: html|plaintext + FilePermissions = gen_mod:get_opt(file_permissions, Opts, {644, 33}), CSSFile = gen_mod:get_opt(cssfile, Opts, false), AccessLog = gen_mod:get_opt(access_log, Opts, muc_admin), Timezone = gen_mod:get_opt(timezone, Opts, local), @@ -141,6 +143,7 @@ init([Host, Opts]) -> dir_type = DirType, dir_name = DirName, file_format = FileFormat, + file_permissions = FilePermissions, css_file = CSSFile, access = AccessLog, lang = Lang, @@ -318,11 +321,16 @@ htmlize_nick(Nick1, html) -> htmlize_nick(Nick1, plaintext) -> htmlize(?PLAINTEXT_IN++Nick1++?PLAINTEXT_OUT, plaintext). +set_filemode(Fn, {FileMode, FileGroup}) -> + ok = file:change_mode(Fn, list_to_integer(integer_to_list(FileMode), 8)), + ok = file:change_group(Fn, FileGroup). + add_message_to_log(Nick1, Message, RoomJID, Opts, State) -> #logstate{out_dir = OutDir, dir_type = DirType, dir_name = DirName, file_format = FileFormat, + file_permissions = FilePermissions, css_file = CSSFile, lang = Lang, timezone = Timezone, @@ -346,6 +354,8 @@ add_message_to_log(Nick1, Message, RoomJID, Opts, State) -> {error, enoent} -> make_dir_rec(Fd), {ok, F} = file:open(Fn, [append]), + catch set_filemode(Fn, FilePermissions), + Datestring = get_dateweek(Date, Lang), TimeStampYesterday = get_timestamp_daydiff(TimeStamp, -1), @@ -499,8 +509,9 @@ make_dir_rec(Dir) -> {error, enoent} -> DirS = filename:split(Dir), DirR = lists:sublist(DirS, length(DirS)-1), - make_dir_rec(filename:join(DirR)), - file:make_dir(Dir) + ok = make_dir_rec(filename:join(DirR)), + ok = file:make_dir(Dir), + ok = file:change_mode(Dir, 8#00755) % -rwxr-xr-x end. |