@@ -28,6 +28,7 @@ static char * ngx_rtmp_hls_merge_app_conf(ngx_conf_t *cf,
2828static ngx_int_t ngx_rtmp_hls_flush_audio (ngx_rtmp_session_t * s );
2929static ngx_int_t ngx_rtmp_hls_ensure_directory (ngx_rtmp_session_t * s ,
3030 ngx_str_t * path );
31+ char * ngx_http_flv_set_permissions_slot (ngx_conf_t * cf , ngx_command_t * cmd , void * conf );
3132
3233
3334#define NGX_RTMP_HLS_BUFSIZE (1024*1024)
@@ -313,7 +314,7 @@ static ngx_command_t ngx_rtmp_hls_commands[] = {
313314
314315 { ngx_string ("hls_dir_access" ),
315316 NGX_RTMP_MAIN_CONF |NGX_RTMP_SRV_CONF |NGX_RTMP_APP_CONF |NGX_CONF_TAKE1 ,
316- ngx_conf_set_num_slot ,
317+ ngx_http_flv_set_permissions_slot ,
317318 NGX_RTMP_APP_CONF_OFFSET ,
318319 offsetof(ngx_rtmp_hls_app_conf_t , dir_access ),
319320 NULL },
@@ -2338,6 +2339,49 @@ ngx_rtmp_hls_variant(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
23382339 return NGX_CONF_OK ;
23392340}
23402341
2342+ char *
2343+ ngx_http_flv_set_permissions_slot (ngx_conf_t * cf , ngx_command_t * cmd , void * conf )
2344+ {
2345+ char * p = conf ;
2346+
2347+ ngx_int_t * np ;
2348+ ngx_str_t * value ;
2349+ ngx_conf_post_t * post ;
2350+ ngx_uint_t i ;
2351+ ngx_uint_t f ;
2352+
2353+ np = (ngx_int_t * ) (p + cmd -> offset );
2354+
2355+ if (* np != NGX_CONF_UNSET ) {
2356+ return "is duplicate" ;
2357+ }
2358+
2359+ value = cf -> args -> elts ;
2360+ if (value [1 ].data [0 ] != '0' ) {
2361+ return "invalid octal : should start with 0" ;
2362+ }
2363+ if (value [1 ].len != 4 ) {
2364+ return "invalid permission mask : should be exactly 4 characters long" ;
2365+ }
2366+ * np = 0 ;
2367+ f = 64 ;
2368+
2369+ for (i = 1 ; i < value [1 ].len ; i ++ ) {
2370+ if (value [1 ].data [i ] < '0' || value [1 ].data [i ] > '7' ) {
2371+ return "invalid octal number" ;
2372+ }
2373+ * np += (value [1 ].data [i ] - '0' ) * f ;
2374+ f /= 8 ;
2375+ }
2376+
2377+ if (cmd -> post ) {
2378+ post = cmd -> post ;
2379+ return post -> post_handler (cf , post , np );
2380+ }
2381+
2382+ return NGX_CONF_OK ;
2383+ }
2384+
23412385
23422386static void *
23432387ngx_rtmp_hls_create_app_conf (ngx_conf_t * cf )
0 commit comments