如何允许 wine 访问网络共享?

如何允许 wine 访问网络共享?

我刚刚从头安装了 14.04,并借助 wine(来自 ppa 的 1.7.17)使 MS Word 正常运行。

问题是我无法通过 wine 访问我的网络驱动器共享(我在办公室局域网中)。

使用旧版 Ubuntu 11.10,我刚刚在 MS Word 中打开了 .doc 文件并进行了编辑,现在看来 wine 无法访问已在 nautilus 中安装的 samba 共享。

该问题似乎与 Ubuntu 安装网络共享方式的近期变化有关:

旧目录:/home/*username*/.gvfs
已被替换为:/run/user/1000/gvfs

挂载的共享名称无法从 wine 中读取(因此它尝试直接从 MS word 打开文件夹)

答案1

我找到了一个解决方法。
我使用的是 13.04,但我认为是一样的。
解决方案是将 GVFS 文件夹链接到另一个名称。

在以下位置创建此文件 (gvfs-patch) /usr/share/playonlinux/bash

sudo -H gedit /usr/share/playonlinux/bash/gvfs-patch  
#!/bin/bash

LOGFILE=/dev/null

GVFS_HOME=/run/user/$USER/gvfs

# Create BASE folder
BASE=/tmp/POL-$USER-gvfs
if [ ! -d "$BASE" ]; then
   echo "Create BASE folder : $BASE" >> $LOGFILE
   rm -fr $BASE
   mkdir $BASE
else
   echo "BASE folder exists : $BASE" >> $LOGFILE
fi

# Clean old symbolic link
for SHARE in $(ls "$BASE"); do
   if [[ ! -e "$BASE/$SHARE" && -h "$BASE/$SHARE" ]]; then
      echo "Remove OLD share folder : $SHARE" >> /tmp/diego.txt
      rm -f "$BASE/$SHARE"
   else
      echo "Share folder valid : $SHARE" >> $LOGFILE
   fi
done

# Create symbolic link for ALL share
for SHARE in $(ls "$GVFS_HOME"); do
   NSHARE=$(echo $SHARE | sed 's/:/-/g')
   if [ ! -e "$BASE/$NSHARE" ]; then
      echo "Create share folder : $NSHARE" >> $LOGFILE
      ln -s "$GVFS_HOME/$SHARE" "$BASE/$NSHARE"
   else
      echo "Share folder valid : $BASE/$NSHARE" >> $LOGFILE
   fi
done

echo $1 | sed "s|$GVFS_HOME|$BASE|g" | sed 's/:/-/g'

使其可执行

sudo chmod +x /usr/share/playonlinux/bash/gvfs-patch  
sudo chown root.root /usr/share/playonlinux/bash/gvfs-patch  

修补此文件:/usr/share/playonlinux/bash/document_reader

sudo -H gedit /usr/share/playonlinux/bash/document_reader

在第 43 行(realpath=... 之前)添加以下内容:

doc=$($PLAYONLINUX/bash/gvfs-patch "$doc")

答案2

根据 Diego 的回答,我将其集成到 Wine 包装器中,可用于经典 Wine 安装。我仅针对 Wine 以“wine start”运行的特定实例,其中路径是第 4 个参数,但这可以扩展为遍历所有参数以测试路径名。

对我来说,文件夹中/run/user是我的 UID 而不是用户名。

在以下位置创建此文件(wine)/usr/local/bin

sudo -H gedit /usr/local/bin/wine

添加以下内容:

#!/bin/bash

LOGFILE=/dev/null
GVFS_HOME=/run/user/`id -u $USERID`/gvfs
BASE=/tmp/POL-$USER-gvfs

setupgvfstmp() {
  # Create BASE folder
  if [ ! -d "$BASE" ]; then
     echo "Create BASE folder : $BASE" >> $LOGFILE
     rm -fr $BASE
     mkdir $BASE
  else
     echo "BASE folder exists : $BASE" >> $LOGFILE
  fi

  # Clean old symbolic link
  for SHARE in $(ls "$BASE"); do
     if [[ ! -e "$BASE/$SHARE" && -h "$BASE/$SHARE" ]]; then
        echo "Remove OLD share folder : $SHARE" >> /tmp/diego.txt
        rm -f "$BASE/$SHARE"
     else
        echo "Share folder valid : $SHARE" >> $LOGFILE
     fi
  done

  # Create symbolic link for ALL share
  for SHARE in $(ls "$GVFS_HOME"); do
     NSHARE=$(echo $SHARE | sed 's/:/-/g')
     if [ ! -e "$BASE/$NSHARE" ]; then
        echo "Create share folder : $NSHARE" >> $LOGFILE
        ln -s "$GVFS_HOME/$SHARE" "$BASE/$NSHARE"
     else
        echo "Share folder valid : $BASE/$NSHARE" >> $LOGFILE
     fi
  done
}

if [ "$1" = "start" ] &&  [ -e "$4" ]; then
  # This only fiddles with stuff if the path is in $4, cos thats what my desktop shortcuts seem to do
  #env WINEPREFIX="/home/phil/.wine" wine start /ProgIDOpen Excel.Sheet.12 %f
  START=$1
  WHAT=$2
  FLAG=$3
  TARGET=$4
  shift 4
  echo "$TARGET" | grep $GVFS_HOME > /dev/null 2>&1
  if [ "$?" == 0 ]; then
    # Because gvfs sometimes hangs for me, only do this if the path is in gvfs
    setupgvfstmp
    TARGET=`echo $TARGET | sed "s|$GVFS_HOME|$BASE|g" | sed 's/:/-/g'`
  fi
  /usr/bin/wine "$START" "$WHAT" "$FLAG" "$TARGET" "$@"
else
  /usr/bin/wine "$@"
fi

使其可执行

sudo chmod +x /usr/local/bin/wine 

确保它/usr/local/bin在你的 $PATH 中,并且位于 之前/usr/bin

相关内容