[MPlayer-cvslog] r23409 - in trunk: cfg-mplayer.h libmenu/menu_filesel.c

ben subversion at mplayerhq.hu
Tue May 29 20:49:38 CEST 2007


Author: ben
Date: Tue May 29 20:49:38 2007
New Revision: 23409

Log:
new -menu-chroot option that prevent OSD file selection menu to go to an unwanted location (yeah, chroot ;-))

Modified:
   trunk/cfg-mplayer.h
   trunk/libmenu/menu_filesel.c

Modified: trunk/cfg-mplayer.h
==============================================================================
--- trunk/cfg-mplayer.h	(original)
+++ trunk/cfg-mplayer.h	Tue May 29 20:49:38 2007
@@ -71,6 +71,7 @@ extern int WinID;
 #ifdef HAVE_MENU
 extern int menu_startup;
 extern int menu_keepdir;
+extern char *menu_chroot;
 #ifdef  USE_FRIBIDI
 extern char *menu_fribidi_charset;
 extern int menu_flip_hebrew;
@@ -298,6 +299,7 @@ m_option_t mplayer_opts[]={
 	{"menu-cfg", &menu_cfg, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL},
 	{"menu-startup", &menu_startup, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
 	{"menu-keepdir", &menu_keepdir, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
+	{"menu-chroot", &menu_chroot, CONF_TYPE_STRING, 0, 0, 0, NULL},
 #ifdef USE_FRIBIDI
 	{"menu-fribidi-charset", &menu_fribidi_charset, CONF_TYPE_STRING, 0, 0, 0, NULL},
 	{"menu-flip-hebrew", &menu_flip_hebrew, CONF_TYPE_FLAG, 0, 0, 1, NULL},

Modified: trunk/libmenu/menu_filesel.c
==============================================================================
--- trunk/libmenu/menu_filesel.c	(original)
+++ trunk/libmenu/menu_filesel.c	Tue May 29 20:49:38 2007
@@ -30,6 +30,7 @@
 #define MENU_KEEP_PATH "/tmp/mp_current_path"
 
 int menu_keepdir = 0;
+char *menu_chroot = NULL;
 
 struct list_entry_s {
   struct list_entry p;
@@ -222,6 +223,12 @@ static int open_dir(menu_t* menu,char* a
   while ((dp = readdir(dirp)) != NULL) {
     if(dp->d_name[0] == '.' && strcmp(dp->d_name,"..") != 0)
       continue;
+    if (menu_chroot && !strcmp (dp->d_name,"..")) {
+      int len = strlen (menu_chroot);
+      if ((strlen (mpriv->dir) == len || strlen (mpriv->dir) == len + 1)
+          && !strncmp (mpriv->dir, menu_chroot, len))
+        continue;
+    }
     mylstat(args,dp->d_name,&st);
     if (file_filter && extensions && !S_ISDIR(st.st_mode)) {
       if((ext = strrchr(dp->d_name,'.')) == NULL)



More information about the MPlayer-cvslog mailing list