CIFS 客户端在服务器上以 root 身份运行

CIFS 客户端在服务器上以 root 身份运行

我有一个 CIFS 客户端,其中有一个普通用户。我有一个 SAMBA 服务器,其中唯一的用户是 root。我希望客户端系统上的用户能够以 root 身份访问远程服务器上的文件。到目前为止,我无法访问,即使我使用了“uid”、“setuid”等选项。客户端只将远程文件视为属于“root”,而我得到的只是“权限被拒绝”。

服务器运行开放电气工程,以访客权限共享,因此该解决方案不太可能涉及对服务器的重大更改。客户端运行的是 Ubuntu 14.04.02。

这是 samba.conf 文件,我认为它会覆盖 smb.conf。我从模板中获取它并仅添加了最后一个共享:

###############################################################################
#      This file is part of OpenELEC - ...
#      Copyright (C) 2009-2014 Stephan Raue ([email protected])
#
#  OpenELEC is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 2 of the License, or
#  (at your option) any later version.
#
#  OpenELEC is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with OpenELEC.  If not, see <.../licenses/>.
################################################################################
# samba.conf

# This configuration file allows you to customize the samba shares
# available from your machine

[global]
  server string = OpenELEC
  workgroup = WORKGROUP
  netbios name = %h
  security = share
  guest account = root
  socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536
  smb ports = 445
  max protocol = SMB2
  min receivefile size = 16384
  deadtime = 30
  os level = 20
  mangled names = no
  syslog only = yes
  syslog = 2
  name resolve order = lmhosts wins bcast host
  preferred master = auto
  domain master = auto
  local master = yes
  printcap name = /dev/null
  load printers = no
  browseable = yes
  writeable = yes
  printable = no
  encrypt passwords = true
  enable core files = no
  passdb backend = smbpasswd
  smb encrypt = disabled
  use sendfile = yes


# Using the following configurations as a template allows you to add
# writable shares of disks and paths under /storage

[Update]
  path = /storage/.update
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/.update

[Videos]
  path = /storage/videos
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/videos

[Music]
  path = /storage/music
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/music

[TV Shows]
  path = /storage/tvshows
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/tvshows

[Recordings]
  path = /storage/recordings
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/recordings

[Downloads]
  path = /storage/downloads
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/downloads

[Pictures]
  path = /storage/pictures
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/pictures

[Emulators]
  path = /storage/emulators
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/emulators

[Configfiles]
  path = /storage/.config
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/.config

[Userdata]
  path = /storage/.kodi/userdata
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/.kodi/userdata

[Screenshots]
  path = /storage/screenshots
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/screenshots

[Logfiles]
  path = /storage/logfiles
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/logfiles
  root preexec = createlog

[Backup]
  path = /storage/backup
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/backup

[HDD]
  path = /var/media/sda1-ata-ST9320325AS_5VEA
  available = yes
  browsable = yes
  public = yes
  writeable = yes
  force user = root
  force group = root

这是在只读文件系统上出现的 smb.conf。同样,我认为它被完全覆盖了:

################################################################################
#      This file is part of OpenELEC - ...
#      Copyright (C) 2009-2014 Stephan Raue ([email protected])
#
#  OpenELEC is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 2 of the License, or
#  (at your option) any later version.
#
#  OpenELEC is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with OpenELEC.  If not, see <...>.
################################################################################
# samba.conf

# This configuration file allows you to customize the samba shares
# available from your machine

[global]
  server string = OpenELEC
  workgroup = WORKGROUP
  netbios name = %h
  security = share
  guest account = root
  socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536
  smb ports = 445
  max protocol = SMB2
  min receivefile size = 16384
  deadtime = 30
  os level = 20
  mangled names = no
  syslog only = yes
  syslog = 2
  name resolve order = lmhosts wins bcast host
  preferred master = auto
  domain master = auto
  local master = yes
  printcap name = /dev/null
  load printers = no
  browseable = yes
  writeable = yes
  printable = no
  encrypt passwords = true
  enable core files = no
  passdb backend = smbpasswd
  smb encrypt = disabled
  use sendfile = yes


# Using the following configurations as a template allows you to add
# writable shares of disks and paths under /storage

[Update]
  path = /storage/.update
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/.update

[Videos]
  path = /storage/videos
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/videos

[Music]
  path = /storage/music
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/music

[TV Shows]
  path = /storage/tvshows
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/tvshows

[Recordings]
  path = /storage/recordings
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/recordings

[Downloads]
  path = /storage/downloads
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/downloads

[Pictures]
  path = /storage/pictures
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/pictures

[Emulators]
  path = /storage/emulators
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/emulators

[Configfiles]
  path = /storage/.config
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/.config

[Userdata]
  path = /storage/.kodi/userdata
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/.kodi/userdata

[Screenshots]
  path = /storage/screenshots
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/screenshots

[Logfiles]
  path = /storage/logfiles
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/logfiles
  root preexec = createlog

[Backup]
  path = /storage/backup
  available = yes
  browsable = yes
  public = yes
  writable = yes
  root preexec = mkdir -p /storage/backup

日志文件几乎不存在:

[2015/05/21 09:52:27, 0] /home/stephan/projects/openelec-5.0/build.OpenELEC-RPi.arm-5.0.8/samba-3.6.25/source3/smbd/server.c:1074(smbd_main) smbd 版本 3.6.25 已启动。版权所有 Andrew Tridgell 和 Samba 团队 1992-2011

答案1

我发现了一个有点肮脏的解决方案:

  1. 启动 PCManFM
  2. 导航到 smb 共享,打开它
  3. 当我使用另一个不认识 smb 的应用程序时,我发现文件浏览器中可以使用该共享。很可能,这是因为它位于/run/user/1000/gvfs/

太糟糕了,但能完成工作。可能有一个更干净的解决方案,涉及 gvfs,这可能是最佳答案。

相关内容