- 3.1 Service Management Facility (SMF)
- 3.2 How SMF Configuration Works
- 3.3 Modifying Solaris Services Defaults
- Further Reading
3.3 Modifying Solaris Services Defaults
On a Solaris system that is hardened by the limited profile, network services that you might want to run on particular systems are disabled (hardening is discussed in Chapter 2, "Hardening Solaris Systems"). For example, the ftp service is disabled, as is NFS file sharing. Services that require configuration, such as IPfilter and IPsec, are disabled by default.
The following sections provide examples of using SMF to configure a system for a particular purpose. Once you have configured the system, the manifest is in the repository. When the system reboots, that configuration is restored. The examples illustrate the following points.
- Services that must be configured in configuration files are enabled after the files are configured. If you did not configure the file, or if the file cannot be read, the problem is recorded in the log file.
- You might want to try different configurations of a service. By using different configuration files, you can create testing environments. The final configuration state is restored at reboot.
- Some services, such as FTP, are necessary but might require monitoring. You can set up monitoring services before bringing them online, thereby ensuring that the service is in compliance with site security policy for its first use.
- You might want to limit the attack surface on a network service. The Apache2 Web service can be configured to use RBAC to limit the privileges that the service uses. You can also require a more limited account than root to run the service.
3.3.1 Configuring the NFS Service
To configure a service that requires you to customize a configuration file, you perform the following steps.
- List the status of the service.
- Modify or create the configuration file.
- Enable the service.
- Verify that the service is online.
- If the system reports an error, read the service log and then fix the error.
- Test and use the service.
In the following example, you configure a system to serve help documents. The files must be shared read-only.
# svcs -a | grep nfs ... disabled Jan_10 svc:/network/nfs/server:default # vi /etc/dfs/dfstab ... share -F nfs -o ro /export/helpdocs ... # svcadm enable svc:/network/nfs/server # svcs -x svc:/network/nfs/server:default State: online since Tue Jan 20 5:15:05 2009 See: nfsd(1M) See: /var/svc/log/network-nfs-server:default.log Impact: None
If you try to enable a service without its supporting files, view the log file to determine the problem:
# svcs -x svc:/network/nfs/server:default (NFS server) State: disabled since Tue Jan 20 5:10:10 2009 Reason: Temporarily disabled by an administrator. See: http://sun.com/msg/SMF-8000-1S See: nfsd(1M) See: /var/svc/log/network-nfs-server:default.log Impact: This service is not running. # vi /var/svc/log/network-nfs-server:default.log ... No NFS filesystems are shared ...
3.3.2 Configuring the IP Filter Service
Like the NFS service, the IP filter service cannot be enabled until you create a configuration file. Your site's security requirements dictate what configuration rules you place in the file. Some services, such as IPsec, require that each communicating system has a configuration file. To enable a service that requires a configuration file involves the following steps.
- Create the configuration file. Use the man page for the service name if you do not know the name of the configuration file. Then read the configuration file man page for the syntax.
- If syntax verification is available, verify the syntax of the file.
- If the service needs to run on both systems, such as the IPsec service, configure the second system.
- Enable the service on one or both systems.
- Enable the service.
- Verify that the service is running.
In the following examples, you protect a system that includes non-global zones. The IP filter rules protect the global zone and the Web server zone. You first create and add rules to the /etc/ipf/ipf.conf configuration file.
# vi /etc/ipf/ipf.conf set intercept_loopback true; # *** GLOBAL ZONE: (IN: TCP/22, OUT: ANYTHING) pass in quick proto tcp from any to global-zone port = 22 keep state keep frags pass out quick from global-zone to any keep state keep frags # *** Web Server ZONE: (IN: TCP/80, OUT: NOTHING) pass in quick proto tcp from any to websvc port = 80 keep state keep frags block out quick from websvc to any # *** DEFAULT DENY block in log all block in from any to 255.255.255.255 block in from any to 127.0.0.1/32
Then you verify the syntax of the configuration file before enabling the service.
# ipf /etc/ipf/ipf.conf # svcs -a | grep ipf disabled Dec_10 svc:/network/ipfilter:default # svcadm enable svc:/network/ipfilter:default # svcs ipfilter enabled Jan_10 svc:/network/ipfilter:default
To test a different configuration, you create another configuration file, verify the syntax of the file, and change the config/entities property to point to the new file. This test file adds rules for the Web data zone.
# vi /etc/ipf/testipf.conf set intercept_loopback true; # *** GLOBAL ZONE: (IN: TCP/22, OUT: ANYTHING) pass in quick proto tcp from any to global-zone port = 22 keep state keep frags pass out quick from global-zone to any keep state keep frags # *** Web Server ZONE: (IN: TCP/80, OUT: NOTHING) pass in quick proto tcp from any to websvc port = 80 keep state keep frags block out quick from websvc to any # *** Web Data ZONE: (IN: TCP/22, OUT: ANYTHING) pass in quick proto tcp from any to webdat port = 22 keep state keep frags pass out quick from webdat to any keep state keep frags # *** DEFAULT DENY block in log all block in from any to 255.255.255.255 block in from any to 127.0.0.1/32 # ipf /etc/ipf/testipf.conf # svcprop ipfilter | grep config config/entities fmri file://localhost/etc/ipf/ipf.conf config/grouping astring require_all config/restart_on astring restart config/type astring path # svccfg -s /network/ipfilter \ setprop config/entities=file://localhost/etc/ipf/testipf.conf
After you refresh and restart the service, you then verify that the property has been set.
# svcadm refresh ipfilter # svcadm restart ipfilter # svcprop ipfilter | grep etc config/entities fmri file://localhost/etc/ipf/testipf.conf
After testing is complete, you can restore the original file.
# svccfg -s /network/ipfilter \ setprop config/entities=file://localhost/etc/ipf/ipf.conf # svcadm refresh ipfilter # svcadm restart ipfilter # svcprop ipfilter | grep etc config/entities fmri file://localhost/etc/ipf/ipf.conf
3.3.3 Configuring the ftp Service
The ftp service is controlled by the inetd command. Often, site security policy requires that an FTP server log detailed records of all FTP connections. In the following two examples, you configure properties of the ftp service that log transactions and turn on debugging.
To configure a service that requires you to change service properties, you perform the following steps.
- List the status of the service.
- List the properties of the service.
- Change one or more properties of the service.
- Verify that the service property is changed.
- Enable the service.
- Verify that the property change is effective.
In the first part of this example, you configure FTP to log every login on System A, the FTP server. Note that the ftp service is initially disabled on System A.
A # svcs ftp STATE STIME FMRI disabled Jan_10 svc:/network/ftp:default A # inetadm -l svc:/network/ftp:default SCOPE NAME=VALUE name="ftp" endpoint_type="stream" proto="tcp6" isrpc=FALSE wait=FALSE exec="/usr/sbin/in.ftpd -a" user="root" ... default tcp_trace=FALSE default tcp_wrappers=FALSE default connection_backlog=10
The login log property for the ftp service is tcp_trace. You change the value from FALSE to TRUE, then enable the service and verify that the service is online.
A # inetadm -m svc:/network/ftp:default tcp_trace=TRUE A # inetadm -l svc:/network/ftp:default SCOPE NAME=VALUE name="ftp" ... tcp_trace=TRUE ... A # svcadm enable svc:/network/ftp:default A # svcs ftp STATE STIME FMRI online 07:07:07 svc:/network/ftp:default
Then, as a regular user, run the ftp command from machine B.
B $ ftp A Connected to A. 220 A FTP server ready. Name (A:testftp): 331 Password required for testftp. Password: 230 User testftp logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp>
As superuser, examine the login record in the log file on machine A.
A # tail -1 /var/adm/messages Jan 10 07:20:20 A inetd[16208]: [ID 317013 daemon.notice] ftp[6036] from B 49822
To continue with this example, disable the service. You want to establish monitoring before the service is online.
A # svcadm disable ftp A # svcs -x ftp svc:/network/ftp:default (FTP server) State: disabled since January 20, 2009 07:20:22 AM PST Reason: Disabled by an administrator. See: http://sun.com/msg/SMF-8000-05 See: in.ftpd(1M) See: ftpd(1M) Impact: This service is not running.
The exec property for the ftp service contains the command that is executed to start the service. The man page for that command describes the arguments that the command accepts. You can select arguments to add to the exec property so that the command runs with those arguments when the service starts. Therefore, to modify the command that runs a service, you perform the following steps.
- List the exec property of the service.
- From the man page, determine the arguments to the service's exec command.
- Add selected arguments to the exec property of the service.
- Verify that the exec property is changed.
- Enable the service.
- Test and use the service.
In the following example, you modify the ftp service to provide debugging information and a detailed log of each transaction. To modify the exec property of the ftp service, first list the exec property, then read the man page of the exec command to determine which arguments to pass to the command.
# inetadm -l svc:/network/ftp:default | grep exec exec="/usr/sbin/in.ftpd -a" # man in.ftpd
From the in.ftpd(1M) man page, select the options that provide detailed information.
- -v Write debugging information to syslogd(1M).
- -w Record each user login and logout in the wtmpx(4) file.
- -i Log the names of all files received by the FTP Server to xferlog(4).
Modify the exec property for the service and verify that the property is changed.
# inetadm -m ftp exec="/usr/sbin/in.ftpd -a -i -v -w" # inetadm -l ftp | grep exec exec="/usr/sbin/in.ftpd -a -i -v -w"
Test that the property change is effective. First, enable the service. Then, as a regular user, transfer a file. Finally, verify that the log file was updated.
A # svcadm enable svc:/network/ftp:default A # svcs ftp STATE STIME FMRI online 07:07:07 svc:/network/ftp:default
As a regular user, try to put a file in the FTP repository.
B $ ftp A Connected to A. 220 A FTP server ready. Name (A:testftp): 331 Password required for testftp. Password: 230 User testftp logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> mput design.tar mput design.tar? y 200 PORT command successful. 150 Opening BINARY mode data connection for design.tar. 226 Transfer complete. ^D ftp> 221-You have transferred 0 bytes in 0 files. 221-Total traffic for this session was 361 bytes in 0 transfers. 221-Thank you for using the FTP service on A. 221 Goodbye. B $
As superuser, examine the record in the xferlog file. The log indicates that the user's attempt to transfer the design.tar file from B to A was unsuccessful.
A # cat /var/log/xferlog Sat Jan 20 07:18:10 2009 1 B.mydomain.com 0 /home/test/design.tar b _ i r test ftp 0 * c
3.3.4 Configuring the Apache2 Web Service
The Apache2 Web server program is offered as part of the Solaris OS. Web servers are frequently the targets of attackers. You can use RBAC to limit the server's vulnerability to attack. Other Solaris features, such as zones, are also useful when setting up network services.
To configure a service with RBAC, you perform some of the following steps.
- List the properties of the service.
- Create a rights profile, or a role, or authorizations for the service.
- Add privileges to or remove privileges from the service.
- Verify that the service properties are changed.
- Enable the service.
- Verify that the property change is effective.
The Apache2 Web server program is provided in the SUNWapch2r and SUNWapch2u packages. By default, the Apache2 service is disabled.
# svcs apache2 disabled 11:11:10 svc:/network/http:apache2
By default, services are started with the root account. However, the http.conf file for the Apache2 service creates a daemon, webservd, to run the service. When you configure the service with the default files, the service starts under the root account, switches to the webservd account, and runs with all privileges.
To reduce the privileges of the Apache2 server and start the service with webservd, do the following.
- Remove basic privileges that the service does not need, proc_session, proc_info, and file_link_any.
- Add the network privilege the service needs to use a privileged port, net_privaddr.
- Do not change the limit set.
- Set the user and group to webservd. When the user and group are set in the SMF manifest, the service starts as webservd, not as root.
# svccfg -s apache2 ... apache2> setprop start/user = astring: webservd ... apache2> setprop start/group = astring: webservd ... apache2> setprop start/privileges = astring: basic,!proc_session,!proc_info,!file_link_any,net_privaddr ... apache2> end # svcadm -v refresh apache2 Action refresh set for svc:/network/http:apache2.
To verify that this configuration has been set, examine the service's start properties.
# svcprop -v -p start apache2 start/exec astring /lib/svc/method/http-apache2\ start ... start/user astring webservd start/group astring webservd start/privileges astring basic,!proc_session,!proc_info,!file_link_any,net_privaddr start/limit_privileges astring :default start/use_profile boolean false ...
You can now enable the service. Verify that the service starts under webservd and has a limited set of privileges.
# svcadm -v enable -s apache2 svc:/network/http:apache2 enabled. # svcs apache2 STATE STIME FMRI online 12:02:21 svc:/network/http:apache2 # ps -aef | grep apache | grep -v grep webservd 5568 5559 0 12:02:22 ? 0:00 /usr/apache2/bin/httpd -k start ... # ppriv -S 5559 5559: /usr/apache2/bin/httpd -k start flags = <none> E: net_privaddr,proc_exec,proc_fork I: net_privaddr,proc_exec,proc_fork P: net_privaddr,proc_exec,proc_fork L: limit
For more examples of using RBAC in SMF manifests, see Chapter 5, "Privileges and Role-Based Access Control."