ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Samba共享目录的多用户权限设置案例

2021-05-28 14:01:49  阅读:190  来源: 互联网

标签:samba 多用户 root yusansan server Samba 存档 权限 data


Samba共享目录的多用户权限设置案例

 

下面根据实际工作中遇到的一个共享目录的多用户权限需求案例来说明下Samba用户权限的设置。

一、需求场景
领导:李一(liyi)
正式员工(zhengshiyuangong):刘二二(liuerer)、于三三(yusansan)、车四四(chesisi)、冯五五(fengwuwu)
实习生(shixisheng):步六六(buliuliu)、王七七(wangqiqi)

李一有整个共享盘的读写权限,其中共享盘整体分为存档区和编辑区,子目录按照如下顺序进行展示。
具体权限设置如下:

二、Samba服务器部署

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

1)安装Samba

[root@samba-server ~]# cat /etc/redhat-release

CentOS Linux release 7.4.1708 (Core)

[root@samba-server ~]# rpm -qa|grep samba

[root@samba-server ~]# yum install -y samba

      

2)安全角度考虑,需要设置防火墙策略(不要关闭防火墙)

添加samba服务到防火墙策略中

[root@samba-server ~]# firewall-cmd --add-service samba --permanent

success

        

重启防火墙

[root@samba-server ~]# firewall-cmd --reload

success

        

查看samba服务是否添加到防火墙中:

[root@samba-server ~]# firewall-cmd --list-all|grep samba

  services: ssh dhcpv6-client samba

         

一定要关闭selinux(否则会造成windows客户机连接Samba失败)

[root@samba-server ~]# vim /etc/sysconfig/selinux

.....

SELINUX=disabled

       

[root@samba-server kevin]# setenforce 0

[root@samba-server kevin]# getenforce

Permissive

      

3)Samba服务配置

[root@samba-server ~]# cat /etc/samba/smb.conf

# See smb.conf.example for a more detailed config file or

# read the smb.conf manpage.

# Run 'testparm' to verify the config is correct after

# you modified it.

      

[global]

    workgroup = SAMBA

    security = user

      

    passdb backend = tdbsam

      

    printing = cups

    printcap name = cups

    load printers = yes

    cups options = raw

      

[homes]

    comment = Home Directories

    valid users = %S, %D%w%S

    browseable = No

    read only = No

    inherit acls = Yes

      

[printers]

    comment = All Printers

    path = /var/tmp

    printable = Yes

    create mask = 0600

    browseable = No

      

[print$]

    comment = Printer Drivers

    path = /var/lib/samba/drivers

    write list = root

    create mask = 0664

    directory mask = 0775

      

[公司共享目录]

       comment = "公司共享目录下的账号权限"

       path= /data/samba

       public = no

       valid users = liyi,chesisi,yusansan,liuerer,fengwuwu,buliuliu,wangqiqi,@samba

       printable = no

       write list = liyi,chesisi,yusansan,liuerer,fengwuwu,buliuliu,wangqiqi

      

4)创建共享目录

[root@samba-server ~]# useradd samba

[root@samba-server ~]# mkdir -p /data/samba/编辑区

[root@samba-server ~]# mkdir -p /data/samba/存档区

[root@samba-server ~]# chown -R samba.samba /data/samba

[root@samba-server ~]# cd /data/samba

[root@samba-server data]# ll samba

总用量 0

drwxr-xr-x  7 samba samba 142 3月  28 03:52 编辑区

drwxr-xr-x 12 samba samba 280 3月  28 03:51 存档区

      

5)添加各samba账号

[root@samba-server ~]# useradd -d /data/samba -s /sbin/nologin liyi

[root@samba-server ~]# useradd -d /data/samba -s /sbin/nologin chesisi

[root@samba-server ~]# useradd -d /data/samba -s /sbin/nologin yusansan

[root@samba-server ~]# useradd -d /data/samba -s /sbin/nologin liuerer

[root@samba-server ~]# useradd -d /data/samba -s /sbin/nologin fengwuwu

[root@samba-server ~]# useradd -d /data/samba -s /sbin/nologin buliuliu

[root@samba-server ~]# useradd -d /data/samba -s /sbin/nologin wangqiqi

[root@samba-server ~]# useradd -d /data/samba -s /sbin/nologin zhengshiyuangong

[root@samba-server ~]# useradd -d /data/samba -s /sbin/nologin shixisheng

      

[root@samba-server ~]# pdbedit -a -u liyi

new password:                      

retype new password:

.......

      

[root@samba-server ~]# pdbedit -a -u chesisi

new password:                      

retype new password:

.......

      

[root@samba-server ~]# pdbedit -a -u yusansan

new password:                      

retype new password:

.......

      

[root@samba-server ~]# pdbedit -a -u liuerer

new password:                      

retype new password:

.......

      

[root@samba-server ~]# pdbedit -a -u fengwuwu

new password:                      

retype new password:

.......

      

[root@samba-server ~]# pdbedit -a -u buliuliu

new password:                      

retype new password:

.......

      

[root@samba-server ~]# pdbedit -a -u wangqiqi

new password:                      

retype new password:

.......

      

查看samba账号列表

[root@samba-server ~]# pdbedit -L

yusansan:1001:

liuerer:1004:

fengwuwu:1006:

liyi:1003:

chesisi:1005:

buliuliu:1009:

wangqiqi:1010:

      

6)设置共享目录权限

[root@samba-server samba]# ll

总用量 0

drwxr-xr-x  7 samba samba 142 3月  28 03:52 编辑区

drwxr-xr-x 12 samba samba 280 3月  28 03:51 存档区

[root@samba-server samba]# cd 存档区

      

[root@samba-server 存档区]# mkdir 01-重大事项

[root@samba-server 存档区]# chown -R liyi.liyi /data/samba/存档区/01-重大事项

[root@samba-server 存档区]# chmod -R 700 /data/samba/存档区/01-重大事项

      

[root@samba-server 存档区]# mkdir 02-战略投资

[root@samba-server 存档区]# chown -R liuerer.liuerer /data/samba/存档区/02-战略投资

[root@samba-server 存档区]# chmod -R 700 /data/samba/存档区/02-战略投资

[root@samba-server 存档区]# setfacl -R -m u:fengwuwu:rx /data/samba/存档区/02-战略投资

      

[root@samba-server 存档区]# mkdir 03-战略规划

[root@samba-server 存档区]# chown -R yusansan.yusansan /data/samba/存档区/03-战略规划

[root@samba-server 存档区]# chmod -R 700 /data/samba/存档区/03-战略规划

[root@samba-server 存档区]# setfacl -R -m u:liuerer:rx /data/samba/存档区/03-战略规划

      

[root@samba-server 存档区]# mkdir 04-公司治理

[root@samba-server 存档区]# chown -R yusansan.yusansan /data/samba/存档区/04-公司治理

[root@samba-server 存档区]# chmod -R 700 /data/samba/存档区/04-公司治理

[root@samba-server 存档区]# setfacl -R -m u:chesisi:rwx /data/samba/存档区/04-公司治理

[root@samba-server 存档区]# setfacl -R -m g:zhengshiyuangong:rx /data/samba/存档区/04-公司治理

[root@samba-server 存档区]# gpasswd -a liuerer zhengshiyuangong

[root@samba-server 存档区]# gpasswd -a yusansan zhengshiyuangong

[root@samba-server 存档区]# gpasswd -a chesisi zhengshiyuangong

[root@samba-server 存档区]# gpasswd -a fengwuwu zhengshiyuangong

      

[root@samba-server 存档区]# mkdir 05-股东信息

[root@samba-server 存档区]# chown -R yusansan.yusansan /data/samba/存档区/05-股东信息

[root@samba-server 存档区]# chmod -R 700 /data/samba/存档区/05-股东信息

[root@samba-server 存档区]# setfacl -R -m u:chesisi:rwx /data/samba/存档区/05-股东信息

      

[root@samba-server 存档区]# mkdir 06-上层股东

[root@samba-server 存档区]# chown -R yusansan.yusansan /data/samba/存档区/06-上层股东

[root@samba-server 存档区]# chmod -R 700 /data/samba/存档区/06-上层股东

[root@samba-server 存档区]# setfacl -R -m u:fengwuwu:rwx /data/samba/存档区/06-上层股东

      

[root@samba-server 存档区]# mkdir 07-投关管理

[root@samba-server 存档区]# chown -R fengwuwu.fengwuwu /data/samba/存档区/07-投关管理

[root@samba-server 存档区]# chmod -R 700 /data/samba/存档区/07-投关管理

[root@samba-server 存档区]# setfacl -R -m u:chesisi:rx /data/samba/存档区/07-投关管理

      

[root@samba-server 存档区]# mkdir 08-制度信批

[root@samba-server 存档区]# chown -R yusansan.yusansan /data/samba/存档区/08-制度信批

[root@samba-server 存档区]# chmod -R 700 /data/samba/存档区/08-制度信批

[root@samba-server 存档区]# setfacl -R -m g:zhengshiyuangong:rx /data/samba/存档区/08-制度信批

      

[root@samba-server 存档区]# mkdir 09-部门综合

[root@samba-server 存档区]# chown -R yusansan.yusansan /data/samba/存档区/09-部门综合

[root@samba-server 存档区]# chmod -R 700 /data/samba/存档区/09-部门综合

[root@samba-server 存档区]# setfacl -R -m g:zhengshiyuangong:rwx /data/samba/存档区/09-部门综合

      

[root@samba-server 存档区]# mkdir 10-学习共享

[root@samba-server 存档区]# chown -R yusansan.yusansan /data/samba/存档区/10-学习共享

[root@samba-server 存档区]# chmod -R 700 /data/samba/存档区/10-学习共享

[root@samba-server 存档区]# setfacl -R -m g:zhengshiyuangong:rwx /data/samba/存档区/10-学习共享

[root@samba-server 存档区]# setfacl -R -m g:shixisheng:rx /data/samba/存档区/10-学习共享

[root@samba-server 存档区]# gpasswd -a buliuliu shixisheng

[root@samba-server 存档区]# gpasswd -a wangqiqi shixisheng

      

[root@samba-server 存档区]# cd ../编辑区/

[root@samba-server 编辑区]# mkdir /data/samba/编辑区/01-材料

[root@samba-server 编辑区]# chown -R yusansan.yusansan /data/samba/编辑区/01-材料

[root@samba-server 编辑区]# chmod -R 700 /data/samba/编辑区/01-材料

[root@samba-server 编辑区]# setfacl -R -m u:liuerer:rwx /data/samba/编辑区/01-材料

      

[root@samba-server 编辑区]# mkdir /data/samba/编辑区/02-周报

[root@samba-server 编辑区]# chown -R liuerer.liuerer /data/samba/编辑区/02-周报

[root@samba-server 编辑区]# chmod -R 700 /data/samba/编辑区/02-周报

[root@samba-server 编辑区]# setfacl -R -m u:fengwuwu:rwx /data/samba/编辑区/02-周报

      

[root@samba-server 编辑区]# mkdir /data/samba/编辑区/03-总结

[root@samba-server 编辑区]# chown -R yusansan.yusansan /data/samba/编辑区/03-总结

[root@samba-server 编辑区]# chmod -R 700 /data/samba/编辑区/03-总结

[root@samba-server 编辑区]# setfacl -R -m u:chesisi:rwx /data/samba/编辑区/03-总结

      

[root@samba-server 编辑区]# mkdir /data/samba/编辑区/04-记录

[root@samba-server 编辑区]# chown -R yusansan.yusansan /data/samba/编辑区/04-记录

[root@samba-server 编辑区]# chmod -R 700 /data/samba/编辑区/04-记录

[root@samba-server 编辑区]# setfacl -R -m g:zhengshiyuangong:rwx /data/samba/编辑区/04-记录

      

[root@samba-server 编辑区]# mkdir /data/samba/编辑区/05-人员

[root@samba-server 编辑区]# chown -R yusansan.yusansan /data/samba/编辑区/05-人员

[root@samba-server 编辑区]# chmod -R 700 /data/samba/编辑区/05-人员

[root@samba-server 编辑区]# setfacl -R -m g:zhengshiyuangong:rwx /data/samba/编辑区/05-人员

[root@samba-server 编辑区]# setfacl -R -m g:shixisheng:rwx /data/samba/编辑区/05-人员

      

[root@nextcloud ~]# cd /data/samba/存档区

[root@nextcloud 存档区]# ll

总用量 0

drwxrwx---+ 2 liyiyi      liyiyi      10 3月  28 03:53 01-重大事项

drwxrwx---+ 2 liuerer     liuerer     10 3月  28 00:01 02-战略投资

drwxrwx---+ 2 yusansan    yusansan    10 3月  28 00:05 03-战略规划

drwxrwx---+ 2 yusansan    yusansan    10 3月  28 02:19 04-公司治理

drwxrwx---+ 2 yusansan    yusansan    10 3月  28 02:19 05-股东信息

drwxrwx---+ 2 yusansan    yusansan    10 3月  28 02:20 06-上层股东

drwxrwx---+ 2 fengwuwu    fengwuwu    10 3月  28 02:20 07-投关管理

drwxrwx---+ 2 yusansan    yusansan    10 3月  28 02:23 08-制度信批

drwxrwx---+ 2 yusansan    yusansan    10 3月  28 02:33 09-部门综合

drwxrwx---+ 2 yusansan    yusansan    10 3月  28 03:54 10-学习共享

[root@nextcloud 存档区]# cd ../编辑区/

[root@nextcloud 编辑区]# ll

总用量 0

drwxrwx---+ 2 yusansan    yusansan    10 3月  28 03:56 01-材料

drwxrwx---+ 2 liuerer     liuerer     10 3月  28 02:39 02-周报

drwxrwx---+ 2 yusansan    yusansan    10 3月  28 03:33 03-总结

drwxrwx---+ 2 yusansan    yusansan    10 3月  28 02:41 04-记录

drwxrwx---+ 2 yusansan    yusansan    10 3月  28 02:43 05-人员

      

由于李峰有整个共享盘的读写权限,所以还需给liyi账号设置所有子目录的读写权限

[root@samba-server ~]# setfacl -R -m u:liyi:rwx /data/samba/存档区/01-重大事项

[root@samba-server ~]# setfacl -R -m u:liyi:rwx /data/samba/存档区/02-战略投资

[root@samba-server ~]# setfacl -R -m u:liyi:rwx /data/samba/存档区/03-战略规划

[root@samba-server ~]# setfacl -R -m u:liyi:rwx /data/samba/存档区/04-公司治理

[root@samba-server ~]# setfacl -R -m u:liyi:rwx /data/samba/存档区/05-股东信息

[root@samba-server ~]# setfacl -R -m u:liyi:rwx /data/samba/存档区/06-上层股东

[root@samba-server ~]# setfacl -R -m u:liyi:rwx /data/samba/存档区/07-投关管理

[root@samba-server ~]# setfacl -R -m u:liyi:rwx /data/samba/存档区/08-制度信批

[root@samba-server ~]# setfacl -R -m u:liyi:rwx /data/samba/存档区/09-部门综合

[root@samba-server ~]# setfacl -R -m u:liyi:rwx /data/samba/存档区/10-学习共享

      

[root@samba-server ~]# setfacl -R -m u:liyi:rwx /data/samba/编辑区/01-材料

[root@samba-server ~]# setfacl -R -m u:liyi:rwx /data/samba/编辑区/02-周报

[root@samba-server ~]# setfacl -R -m u:liyi:rwx /data/samba/编辑区/03-总结

[root@samba-server ~]# setfacl -R -m u:liyi:rwx /data/samba/编辑区/04-记录

[root@samba-server ~]# setfacl -R -m u:liyi:rwx /data/samba/编辑区/05-人员

三、在windows本机登录Samba,验证各用户针对各个子目录的读写权限

按键Ctrl+E,打开“此电脑”,然后点击左侧栏的“网络”,接着在上侧的网络栏目里输入samba地址( 比如samba部署机ip为192.168.10.10):\\192.168.10.10,然后输入samba账号和密码,就可以登录到Samba共享目录了了。如上部署后,可以逐个验证各个samba账号对各个子目录的读写权限。

温馨提示:
1)如上配置,登录Samba后,会显示两个目录:一个是账号目录(没有访问权限,不需要访问),一个就是samba共享目录了(在smb.conf里定义的共享名称,这个可以访问),如下图:

2)如何将samba共享目录保存到本地电脑上,从而不需要每次都输入账号和密码信息?
初次登录samba,看到共享目录后,可以右击共享目录,选择"映射网络驱动器",这样就将samba共享目录通过网络驱动器的方式保存到本地了,如下图:

===================================================================
温馨提示:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

以上的权限设置后,还是有一些问题的。就是说,新建文件的权限是没有问题的,但是当一个文件新建后,另一个用户就没有权限去操作了。

比如,yusansan用户在/data/samba/编辑区/05-实习生目录下创建一个test文件,这时test文件的所有者是yusansan,那么fengwuwu等其他用户

就不能对这个test文件进行写操作了。

   

要想解决上面的问题,可以写一个脚本,将上面赋予的权限动作循环执行(写一个简单的死循环脚本,去一直执行),如下:

   

[root@samba-server ~]# cat /opt/samba_quanxian.sh

#!/bin/bash

   

while "1" "1" ]

do

   

#设置存档区权限

/usr/bin/chown -R liyi.liyi /data/samba/存档区/01-重大事项

/usr/bin/chmod -R 700 /data/samba/存档区/01-重大事项

/usr/bin/chown -R liuerer.liuerer /data/samba/存档区/02-战略投资

/usr/bin/chmod -R 700 /data/samba/存档区/02-战略投资

/usr/bin/chown -R yusansan.yusansan /data/samba/存档区/03-战略规划

/usr/bin/chmod -R 700 /data/samba/存档区/03-战略规划

/usr/bin/chown -R yusansan.yusansan /data/samba/存档区/04-公司治理

/usr/bin/chmod -R 700 /data/samba/存档区/04-公司治理

/usr/bin/chown -R yusansan.yusansan /data/samba/存档区/05-股东信息

/usr/bin/chmod -R 700 /data/samba/存档区/05-股东信息

/usr/bin/chown -R yusansan.yusansan /data/samba/存档区/06-上层股东

/usr/bin/chmod -R 700 /data/samba/存档区/06-上层股东

/usr/bin/chown -R fengwuwu.fengwuwu /data/samba/存档区/07-投关管理

/usr/bin/chmod -R 700 /data/samba/存档区/07-投关管理

/usr/bin/chown -R yusansan.yusansan /data/samba/存档区/08-制度信批

/usr/bin/chmod -R 700 /data/samba/存档区/08-制度信批

/usr/bin/chown -R yusansan.yusansan /data/samba/存档区/09-部门综合

/usr/bin/chmod -R 700 /data/samba/存档区/09-部门综合

/usr/bin/chown -R yusansan.yusansan /data/samba/存档区/10-学习共享

/usr/bin/chmod -R 700 /data/samba/存档区/10-学习共享

  

/usr/bin/setfacl -R -m u:fengwuwu:rx /data/samba/存档区/02-战略投资

/usr/bin/setfacl -R -m u:liuerer:rx /data/samba/存档区/03-战略规划

/usr/bin/setfacl -R -m u:chesisi:rwx /data/samba/存档区/04-公司治理

/usr/bin/setfacl -R -m g:zhengshiyuangong:rx /data/samba/存档区/04-公司治理

/usr/bin/setfacl -R -m u:chesisi:rwx /data/samba/存档区/05-股东信息

/usr/bin/setfacl -R -m u:fengwuwu:rwx /data/samba/存档区/06-上层股东

/usr/bin/setfacl -R -m u:chesisi:rx /data/samba/存档区/07-投关管理

/usr/bin/setfacl -R -m g:zhengshiyuangong:rx /data/samba/存档区/08-制度信批

/usr/bin/setfacl -R -m g:zhengshiyuangong:rwx /data/samba/存档区/09-部门综合

/usr/bin/setfacl -R -m g:zhengshiyuangong:rwx /data/samba/存档区/10-学习共享

   

#设置编辑区权限

/usr/bin/chown -R yusansan.yusansan /data/samba/编辑区/01-开蓉开乐

/usr/bin/chmod -R 700 /data/samba/编辑区/01-开蓉开乐

/usr/bin/chown -R liuerer.liuerer /data/samba/编辑区/02-开蓉冯博

/usr/bin/chmod -R 700 /data/samba/编辑区/02-开蓉冯博

/usr/bin/chown -R yusansan.yusansan /data/samba/编辑区/03-开乐一鸣

/usr/bin/chmod -R 700 /data/samba/编辑区/03-开乐一鸣

/usr/bin/chown -R yusansan.yusansan /data/samba/编辑区/04-正式员工

/usr/bin/chmod -R 700 /data/samba/编辑区/04-正式员工

/usr/bin/chown -R yusansan.yusansan /data/samba/编辑区/05-人员

/usr/bin/chmod  -R 700 /data/samba/编辑区/05-人员

  

/usr/bin/setfacl -R -m u:liuerer:rwx /data/samba/编辑区/01-材料

/usr/bin/setfacl -R -m u:fengwuwu:rwx /data/samba/编辑区/02-开蓉冯博

/usr/bin/setfacl -R -m u:chesisi:rwx /data/samba/编辑区/03-开乐一鸣

/usr/bin/setfacl -R -m g:zhengshiyuangong:rwx /data/samba/编辑区/04-正式员工

/usr/bin/setfacl -R -m g:zhengshiyuangong:rwx /data/samba/编辑区/05-实习生

/usr/bin/setfacl -R -m g:shixisheng:rwx /data/samba/编辑区/05-实习生

   

#设置李一总权限

/usr/bin/setfacl -R -m u:liyi:rwx /data/samba/存档区/01-重大事项

/usr/bin/setfacl -R -m u:liyi:rwx /data/samba/存档区/02-战略投资

/usr/bin/setfacl -R -m u:liyi:rwx /data/samba/存档区/03-战略规划

/usr/bin/setfacl -R -m u:liyi:rwx /data/samba/存档区/04-公司治理

/usr/bin/setfacl -R -m u:liyi:rwx /data/samba/存档区/05-股东信息

/usr/bin/setfacl -R -m u:liyi:rwx /data/samba/存档区/06-上层股东

/usr/bin/setfacl -R -m u:liyi:rwx /data/samba/存档区/07-投关管理

/usr/bin/setfacl -R -m u:liyi:rwx /data/samba/存档区/08-制度信批

/usr/bin/setfacl -R -m u:liyi:rwx /data/samba/存档区/09-部门综合

/usr/bin/setfacl -R -m u:liyi:rwx /data/samba/存档区/10-学习共享

   

/usr/bin/setfacl -R -m u:liyi:rwx /data/samba/编辑区/01-材料

/usr/bin/setfacl -R -m u:liyi:rwx /data/samba/编辑区/02-周报

/usr/bin/setfacl -R -m u:liyi:rwx /data/samba/编辑区/03-总结

/usr/bin/setfacl -R -m u:liyi:rwx /data/samba/编辑区/04-记录

/usr/bin/setfacl -R -m u:liyi:rwx /data/samba/编辑区/05-人员

   

done

   

然后执行脚本:

[root@samba-server ~]# nohup sh /opt/samba_quanxian.sh &          //按键ctrl+c

[root@samba-server ~]# ps -ef|grep samba_quanxian.sh

root      83870  82538 61 23:32 pts/0    00:05:17 sh samba_quanxian.sh

root     164997  82538  0 23:41 pts/0    00:00:00 grep --color=auto samba_quanxian.sh

   

这样,在各个区域的目录下创建的文件,就会及时被赋予相应权限。

 

===========================================================================

然而后续又发现了一个问题:

上面循环脚本实时执行后,发现用acl授权的用户访问samba目录时,有时有权访问,有时无权访问(提示没有权限,句柄无效)。

最后将脚本中的循环语句(while,do,done)删除,取消实时执行,在crontab里设置每10秒钟执行一次,调整后问题解决。

[root@samba-server ~]# crontab -l

* * * * * /bin/bash -x /opt/samba_quanxian.sh > /dev/null 2>&1

* * * * * sleep 10;/bin/bash -x /opt/samba_quanxian.sh > /dev/null 2>&1

* * * * * sleep 20;/bin/bash -x /opt/samba_quanxian.sh > /dev/null 2>&1

* * * * * sleep 30;/bin/bash -x /opt/samba_quanxian.sh > /dev/null 2>&1

* * * * * sleep 40;/bin/bash -x /opt/samba_quanxian.sh > /dev/null 2>&1

* * * * * sleep 50;/bin/bash -x /opt/samba_quanxian.sh > /dev/null 2>&1

*************** 当你发现自己的才华撑不起野心时,就请安静下来学习吧!***************

标签:samba,多用户,root,yusansan,server,Samba,存档,权限,data
来源: https://blog.csdn.net/XiaoJiang0505/article/details/117360532

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有