Enabling Browsing with Samba in Solaris 10 Update 4

The default samba service provided with Solaris 10 08/07 provides access to the smb daemon only.
If you wish the shares provided by the machine to be browsable the nmbd(1m) daemon needs to be running.

This can be added as a separate service. But instead we'll change the existing samba service to provide both daemons as separate instances of the samba service.

To obtain the current manifest you should export it from the repository.
Note, the default manifest is distributed as /var/svc/manifest/network/samba.xml and could be used as the starting point.

# svccfg export samba > samba.xml

This gives us the working document we will edit.

The changes we will make are:

  • Because we will not have the default instance after our changes, and because we'll be using two instances, one for smb and one for nmb we delete the lines for create_default_instance and single_instance.
  • We need to wrap the existing start and stop methods into an instance.
  • We have to add an instance for the nmbd daemon with its own start and stop methods.
  • We have to change the documentation links to refer to the nmbd daemon's manpage.

Other changes we can make include:

  • Adding a dependancy on the configuration file, as the default exit value of 255 from the daemons does not match the smf SMF_EXIT_ERR_CONFIG code of 96.
  • Changing the kill method to :kill so that ALL the daemons die when the service is disabled. This affects existing sessions as well as just new sessions.

The modified samba.xml

samba.xml
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
  <service name='network/samba' type='service' version='0'>

<!-- Remove the create_default_instance and single_instance lines -->

    <dependency name='net-loopback' grouping='require_any' restart_on='none' type='service'>
      <service_fmri value='svc:/network/loopback'/>
    </dependency>
    <dependency name='net-service' grouping='require_all' restart_on='none' type='service'>
      <service_fmri value='svc:/network/service'/>
    </dependency>
    <dependency name='net-physical' grouping='require_all' restart_on='none' type='service'>
      <service_fmri value='svc:/network/physical'/>
    </dependency>
    <dependency name='filesystem-local' grouping='require_all' restart_on='none' type='service'>
      <service_fmri value='svc:/system/filesystem/local'/>
    </dependency>

<!-- Add a dependancy for the config file -->

    <dependency name='config_data' grouping='require_all' restart_on='none' type='path'>
      <service_fmri value='file://localhost/etc/sfw/smb.conf'/>
    </dependency>
    <dependent name='samba_multi-user-server' restart_on='none' grouping='optional_all'>
      <service_fmri value='svc:/milestone/multi-user-server'/>
    </dependent>
<!--
        Move the smbd daemon startup methods into an instance.
        We'll call this instance smbd
-->
    <instance name='smbd' enabled='false'>
      <exec_method name='start' type='method' exec='/usr/sfw/sbin/smbd -D' timeout_seconds='170'>
        <method_context/>
      </exec_method>

<!-- change the stop method to kill all the daemons,
        including existing sessions -->

      <exec_method name='stop' type='method' exec=':kill' timeout_seconds='60'>
        <method_context/>
      </exec_method>
    </instance>

<!--    Add the nmbd instance   -->

    <instance name='nmbd' enabled='false'>
      <exec_method name='start' type='method' exec='/usr/sfw/sbin/nmbd -D' timeout_seconds='170'>
        <method_context/>
      </exec_method>
      <exec_method name='stop' type='method' exec=':kill' timeout_seconds='60'>
        <method_context/>
      </exec_method>
    </instance>
    <stability value='Unstable'/>
    <template>
      <common_name>
        <loctext xml:lang='C'>SMB file server</loctext>
      </common_name>
      <documentation>
        <manpage title='smbd' section='1m' manpath='/usr/sfw/man'/>
        <manpage title='nmbd' section='1m' manpath='/usr/sfw/man'/>
        <manpage title='smb.conf' section='4' manpath='/usr/sfw/man'/>
      </documentation>
    </template>
  </service>
</service_bundle>

Enabling The Modifications

# svcadm disable samba
# svccfg import samba.xml
# svccfg delete svc:/network/samba:default
# svcadm refresh samba:smbd
# svcadm refresh samba:nmbd
# svcadm enable samba:smbd
# svcadm enable samba:nmbd

Checking The Result

The svcs command can be used to verify the services are now running, and the nmblookup command can be used to verify the machine is part of the browse group.

# svcs samba
STATE          STIME    FMRI
online          8:34:16 svc:/network/samba:smbd
online          8:35:00 svc:/network/samba:nmbd
# svcs -p samba
STATE          STIME    FMRI
online          8:34:16 svc:/network/samba:smbd
                8:34:16     2038 smbd
                8:34:16     2039 smbd
online          8:35:00 svc:/network/samba:nmbd
                8:35:00     2066 nmbd
# /usr/sfw/bin/nmblookup SMBGROUP
querying SMBGROUP on 192.168.1.255
192.168.1.138 SMBGROUP<00>
192.168.1.134 SMBGROUP<00>
192.168.1.2 SMBGROUP<00>
192.168.1.76 SMBGROUP<00>
192.168.1.1 SMBGROUP<00>
192.168.1.51 SMBGROUP<00>
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Jul 27, 2008

    vmelamedov says:

    Excellent Work... Thank You!

    Excellent Work... Thank You!

  2. Mar 24, 2009

    spit_the-dog says:

    I slipped up editing the xml, i found it easy for me not yet familiar with XML t...

    I slipped up editing the xml, i found it easy for me not yet familiar with XML to make a mistake. There is a useful svccfg command to validate the samba.xml file before importing it.

    svccfg validate samba.xml

    There is the svccfg man page and I also found this useful high level guide to smf, svc, svcs and svccfg configuration which mentioned the svccfg validate option. http://www.filibeto.org/~aduritz/truetrue/solaris10/sol-smf.pdf Many thanks to Ambreesh Khanna for making this available as currently I'm trying to get to know smf, svc .

    If there is/are errors in the xml (and I had a bit of a line left over from a vi yank and put!) then you get lines of xmlly garbage. Does anyone understand this?

    Once the XML file is free of typos introduced by the dumb user (me) and the same command is run, Solaris does the usual helpful Unix thing and exits 0 (no response).

    Many, many thanks as there's no way I could have migrated from init.d without this.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact