diff --git a/forked-daapd.conf.in b/forked-daapd.conf.in index 1a9963c6..b8a5e0fd 100644 --- a/forked-daapd.conf.in +++ b/forked-daapd.conf.in @@ -265,9 +265,14 @@ mpd { # the playqueue if playback is stopped. # clear_queue_on_stop_disable = false + # Allows creating, deleting and modifying m3u playlists in the library directories. + # Defaults to being disabled. +# allow_modifying_stored_playlists = false + # A directory in one of the library directories that will be used as the default # playlist directory. forked-dapd creates new playlists in this directory if only - # a playlist name is provided by the mpd client. + # a playlist name is provided by the mpd client (requires "allow_modify_stored_playlists" + # set to true). # default_playlist_directory = "" } diff --git a/src/conffile.c b/src/conffile.c index b1d8c799..06649d29 100644 --- a/src/conffile.c +++ b/src/conffile.c @@ -156,6 +156,7 @@ static cfg_opt_t sec_mpd[] = CFG_INT("port", 6600, CFGF_NONE), CFG_INT("http_port", 0, CFGF_NONE), CFG_BOOL("clear_queue_on_stop_disable", cfg_false, CFGF_NONE), + CFG_BOOL("allow_modifying_stored_playlists", cfg_false, CFGF_NONE), CFG_STR("default_playlist_directory", NULL, CFGF_NONE), CFG_END() }; diff --git a/src/mpd.c b/src/mpd.c index bd641328..f20b2e41 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -72,6 +72,7 @@ struct evconnlistener *listener; // Virtual path to the default playlist directory static char *default_pl_dir; +static bool allow_modifying_stored_playlists; #define COMMAND_ARGV_MAX 37 @@ -2205,6 +2206,12 @@ mpd_command_playlistadd(struct evbuffer *evbuf, int argc, char **argv, char **er char *vp_item; int ret; + if (!allow_modifying_stored_playlists) + { + *errmsg = safe_asprintf("Modifying stored playlists is not enabled"); + return ACK_ERROR_PERMISSION; + } + if (argc < 3) { *errmsg = safe_asprintf("Missing argument for command 'playlistadd'"); @@ -2242,6 +2249,12 @@ mpd_command_rm(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) char *virtual_path; int ret; + if (!allow_modifying_stored_playlists) + { + *errmsg = safe_asprintf("Modifying stored playlists is not enabled"); + return ACK_ERROR_PERMISSION; + } + if (argc < 2) { *errmsg = safe_asprintf("Missing argument for command 'rm'"); @@ -2276,6 +2289,12 @@ mpd_command_save(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) char *virtual_path; int ret; + if (!allow_modifying_stored_playlists) + { + *errmsg = safe_asprintf("Modifying stored playlists is not enabled"); + return ACK_ERROR_PERMISSION; + } + if (argc < 2) { *errmsg = safe_asprintf("Missing argument for command 'save'"); @@ -4943,6 +4962,7 @@ int mpd_init(void) } } + allow_modifying_stored_playlists = cfg_getbool(cfg_getsec(cfg, "mpd"), "allow_modifying_stored_playlists"); pl_dir = cfg_getstr(cfg_getsec(cfg, "mpd"), "default_playlist_directory"); if (pl_dir) default_pl_dir = safe_asprintf("/file:%s", pl_dir);