Skip to content

Commit

Permalink
Added readonly feature to smbserver.py
Browse files Browse the repository at this point in the history
  • Loading branch information
vflame6 committed Nov 26, 2023
1 parent 4b56c18 commit 088f915
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion examples/smbserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
parser.add_argument('-ip', '--interface-address', action='store', default='0.0.0.0', help='ip address of listening interface')
parser.add_argument('-port', action='store', default='445', help='TCP port for listening incoming connections (default 445)')
parser.add_argument('-smb2support', action='store_true', default=False, help='SMB2 Support (experimental!)')
parser.add_argument('-readonly', action='store_true', default=False, help='Make the share readonly')

if len(sys.argv)==1:
parser.print_help()
Expand All @@ -68,9 +69,14 @@
else:
comment = options.comment

if options.readonly:
readonly = 'yes'
else:
readonly = 'no'

server = smbserver.SimpleSMBServer(listenAddress=options.interface_address, listenPort=int(options.port))

server.addShare(options.shareName.upper(), options.sharePath, comment)
server.addShare(options.shareName.upper(), options.sharePath, comment, readOnly=readonly)
server.setSMB2Support(options.smb2support)

# If a user was specified, let's add it to the credentials for the SMBServer. If no user is specified, anonymous
Expand Down

0 comments on commit 088f915

Please sign in to comment.