1 #!/bin/sh 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License (the "License"). 7 # You may not use this file except in compliance with the License. 8 # 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 # or http://www.opensolaris.org/os/licensing. 11 # See the License for the specific language governing permissions 12 # and limitations under the License. 13 # 14 # When distributing Covered Code, include this CDDL HEADER in each 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 # If applicable, add the following below this CDDL HEADER, with the 17 # fields enclosed by brackets "[]" replaced with your own identifying 18 # information: Portions Copyright [yyyy] [name of copyright owner] 19 # 20 # CDDL HEADER END 21 # 22 # 23 # Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24 # Use is subject to license terms. 25 # 26 # 27 28 PATH="/usr/bin:/usr/sbin:${PATH}" 29 export PATH 30 31 # inetd_fini : clean up temp files 32 inetd_fini() { 33 rm -f -- $inetsed $inettmp $inetsedhdr 34 return 0 35 } 36 37 # inetd_undo : restore original file in case of failure 38 inetd_undo() { 39 cat $inetold > $inetconf 40 inetd_fini 41 } 42 43 # inetd_remove : remove daemons specified as arguments by removing 44 # lines from inetd.conf that match the regular 45 # expressions provided on stdin (one per line) 46 # original file is restored and script exits on failure 47 inetd_remove() { 48 sed -e 's:/:\\/:g' -e 's:.*:/&/ d:' >> $inetsed 49 if [ $? -ne 0 ]; then 50 echo "Unable to append to $inetsed" 51 inetd_undo 52 exit 1 53 fi 54 return 0 55 } 56 57 # We start by building the giant sed script used to clean out the old 58 # bundled entries. Broken up into bite-size sections for easier maintenance 59 60 # Location for scripts 61 inetsed=/tmp/inetd.sed.$$ 62 inetsedhdr=/tmp/inetd.sedhdr.$$ 63 64 # The header editing is built separately so that we only apply it when needed 65 cat >$inetsedhdr <<EOF 66 /^# Copyright .* Sun Microsystems/d 67 /^# Use is subject to license terms/d 68 EOF 69 70 # Remove the traditional introductory comments 71 inetd_remove intro_comment <<EOF 72 ^# Configuration file for inetd(1M). See inetd.conf(4). 73 ^# To re-configure the running inetd process, edit this file, then 74 ^# send the inetd process a SIGHUP. 75 ^# Syntax for socket-based Internet services: 76 ^# <service_name> <socket_type> <proto> <flags> <user> <server_pathname> <args> 77 ^# Syntax for TLI-based Internet services: 78 ^# <service_name> tli <proto> <flags> <user> <server_pathname> <args> 79 EOF 80 81 # Remove the RPC syntax comments 82 inetd_remove rpc_comments <<EOF 83 ^# RPC services syntax: 84 ^# <rpc_prog>/<vers> <endpoint-type> rpc/<proto> <flags> <user> 85 ^# <pathname> <args> 86 ^# <endpoint-type> can be either "tli" or "stream" or "dgram". 87 ^# For "stream" and "dgram" assume that the endpoint is a socket descriptor. 88 ^# <proto> can be either 89 ^# first treated as a nettype. If it is not a valid nettype then it is 90 ^# treated as a netid 91 ^# transports supported by this system, ie. it equates to the "visible" 92 ^# nettype. The syntax for <proto> is: 93 ^#.*<nettype|netid> 94 ^# For example: 95 ^# dummy/1 tli rpc/circuit_v,udp 96 EOF 97 98 # Remove the IPv6 comment which appeared starting in Solaris 8 99 inetd_remove ipv6_comment <<EOF 100 ^# IPv6 and inetd.conf 101 ^# By specifying a <proto> value of tcp6 or udp6 for a service, inetd will 102 ^# pass the given daemon an AF_INET6 socket. The following daemons have 103 ^# been modified to be able to accept AF_INET6 sockets 104 ^# ftp telnet shell login exec tftp finger printer 105 ^# and service connection requests coming from either IPv4 or IPv6-based 106 ^# transports. Such modified services do not normally require separate 107 ^# configuration lines for tcp or udp. For documentation on how to do this 108 ^# for other services, see the Solaris System Administration Guide. 109 ^# You must verify that a service supports IPv6 before specifying <proto> as 110 ^# tcp6 or udp6. Also, all inetd built-in commands (time, echo, discard, 111 ^# daytime, chargen) require the specification of <proto> as tcp6 or udp6 112 ^# The remote shell server (shell) and the remote execution server 113 ^# (exec) must have an entry for both the "tcp" and "tcp6" <proto> values. 114 EOF 115 116 # Remove entries in inetd.conf for r* deamons 117 # This also removes the old SEAM unbundled versions of these services 118 inetd_remove in.rshd in.rlogind in.rexecd in.comsat in.talkd in.fingerd rpc.statd rpc.rusersd rpc.rwalld rpc.sprayd systat netstat <<EOF 119 ^[# ]*shell[ ]*stream 120 ^[# ]*kshell[ ]*stream 121 ^[# ]*login[ ]*stream 122 ^[# ]*klogin[ ]*stream 123 ^[# ]*eklogin[ ]*stream 124 ^[# ]*exec[ ]*stream 125 ^[# ]*comsat[ ]*dgram 126 ^[# ]*talk[ ]*dgram 127 ^[# ]*finger[ ]*stream 128 ^[# ]*rstatd/2-4 129 ^[# ]*rusersd/2-3 130 ^[# ]*walld/1 131 ^[# ]*sprayd/1 132 ^[# ]*systat[ ]*stream 133 ^[# ]*netstat[ ]*stream 134 ^# RSHD 135 ^# RLOGIND 136 ^# REXECD 137 ^# COMSATD 138 ^# TALKD 139 ^# FINGERD 140 ^# RSTATD 141 ^# RUSERSD 142 ^# RWALLD 143 ^# SPRAYD 144 ^# Shell, login, exec, comsat and talk are BSD protocols 145 ^# The spray server is used primarily for testing. 146 ^# The rwall server allows others to post messages to users 147 ^# Rstatd is used by programs such as perfmeter 148 ^#[ ]*.note: Kerberos does not yet support ipv6 149 ^# Finger, systat and netstat give out user information which may be 150 ^# valuable to potential "system crackers." Many sites choose to disable 151 ^# some or all of these services to improve security. 152 ^# The rusers service gives out user information. Sites concerned 153 ^# with security may choose to disable it. 154 EOF 155 156 # Remove entries in inetd.conf for common network service deamons 157 inetd_remove time daytime echo discard chargen <<EOF 158 ^[# ]*time[ ]*stream 159 ^[# ]*time[ ]*dgram 160 ^[# ]*daytime[ ]*stream 161 ^[# ]*daytime[ ]*dgram 162 ^[# ]*echo[ ]*stream 163 ^[# ]*echo[ ]*dgram 164 ^[# ]*discard[ ]*stream 165 ^[# ]*discard[ ]*dgram 166 ^[# ]*chargen[ ]*stream 167 ^[# ]*chargen[ ]*dgram 168 ^# Time service is used for clock synchronization. 169 ^# Echo, discard, daytime, and chargen are used primarily for testing. 170 ^# Daytime provides a legible form of date and time. 171 ^# Echo is used primarily for testing. 172 ^# Discard is used primarily for testing. 173 ^# Chargen is used primarily for testing. 174 EOF 175 176 # Remove entry in inetd.conf for smserverd daemon 177 inetd_remove rpc.smserverd <<EOF 178 ^[# ]*100155/1 179 ^# smserverd 180 EOF 181 182 # Remove entry in inetd.conf for telnetd 183 # Also removes the old SEAM version 184 inetd_remove in.telnetd <<EOF 185 ^[# ]*telnet[ ]*stream 186 ^[# ]*telnet.*/usr/krb5/lib/telnetd 187 ^# TELNETD 188 ^# Ftp and telnet are standard Internet services. 189 EOF 190 191 # Remove entry in inetd.conf for in.tnamed 192 inetd_remove in.tnamed <<EOF 193 ^[# ]*name[ ]*dgram 194 ^# TNAMED 195 ^# Tnamed serves the obsolete IEN-116 name server protocol. 196 EOF 197 198 # Remove entry in inetd.conf for printer daemon 199 inetd_remove in.lpd <<EOF 200 ^[# ]*printer[ ]*stream 201 ^# LPD 202 ^# Print Protocol Adaptor - BSD listener 203 EOF 204 205 # Remove entry in inetd.conf for ocfserv daemon 206 inetd_remove ocfserv <<EOF 207 ^[# ]*100150/1 208 ^# OCFSERV 209 ^# OCF (Smart card) Daemon 210 EOF 211 212 # Remove entry in inetd.conf for rpc.rexd 213 inetd_remove rpc.rexd <<EOF 214 ^[# ]*rexd/1 215 ^# REXD 216 ^# The rexd server provides only minimal authentication 217 EOF 218 219 # Remove entry in inetd.conf for rquotad 220 inetd_remove rquotad <<EOF 221 ^[# ]*rquotad/1 222 ^# RQUOTAD 223 ^# Rquotad supports UFS disk quotas for NFS clients 224 EOF 225 226 # Remove entries in inetd.conf for SLVM daemons 227 inetd_remove rpc.metad rpc.metamhd rpc.metamedd <<EOF 228 ^[# ]*100229/1 229 ^[# ]*100230/1 230 ^[# ]*100242/1 231 ^# METAD 232 ^# METAMHD 233 ^# METAMEDD 234 ^# SLVM Daemons 235 EOF 236 237 # Remove entry in inetd.conf for ktkt_warnd daemon 238 inetd_remove ktkt_warnd <<EOF 239 ^[# ]*100134/1 240 ^# KTKT_WARND 241 ^# Kerberos V5 Warning Message Daemon 242 EOF 243 244 # Remove entries in inetd.conf for kpropd 245 inetd_remove kpropd << EOF 246 ^[# ]*krb5_prop[ ]*stream 247 ^# Kerberos V5 DB Propagation Daemon 248 EOF 249 250 # Remove entry in inetd.conf for GSS daemon 251 inetd_remove gssd <<EOF 252 ^[# ]*100234/1 253 ^# GSSD 254 ^# GSS Daemon 255 EOF 256 257 # Remove entry in inetd.conf for ftp daemon 258 # Also removes the old SEAM entry 259 inetd_remove in.ftpd <<EOF 260 ^[# ]*ftp[ ]*stream 261 ^[# ]*ftp.*/usr/krb5/lib/ftpd 262 ^# FTPD 263 ^# Ftp and telnet are standard Internet services. 264 EOF 265 266 # Remove dr_daemon entry if it is present. 267 inetd_remove dr_daemon <<EOF 268 ^[# ]*300326/4[ ]*tli 269 EOF 270 271 # Remove the DCS entries from /etc/inetd.conf. 272 inetd_remove dcs <<EOF 273 ^[# ]*sun-dr[ ]*stream 274 EOF 275 276 # Remove entry in inetd.conf for uucp daemon 277 inetd_remove in.uucpd <<EOF 278 ^[# ]*uucp[ ]*stream 279 ^# UUCPD 280 ^# Must run as root 281 EOF 282 283 # Not yet converted 284 # Remove cachefsd 285 #inetd_remove cachefsd <<EOF 286 #^[# ]*100235/1[ ]*tli 287 #^# CacheFS Daemon 288 #EOF 289 290 # Remove font server 291 inetd_remove fs <<EOF 292 ^[# ]*fs[ ]*stream 293 ^# Sun Font Server 294 EOF 295 296 # Remove nfsmapid 297 # Only appears in Solaris 10 298 inetd_remove nfsmapid <<EOF 299 ^[# ]*100166/1 300 ^# NFSv4 301 EOF 302 303 # Remove stfsloader 304 inetd_remove stfsloader <<EOF 305 ^[# ]*100424/1 306 ^# Standard Type Services Framework 307 EOF 308 309 # Things below here don't appear after Solaris 9 310 311 # Remove KCMS 312 inetd_remove kcms_server <<EOF 313 ^[# ]*100221/1[ ]*tli 314 ^# Sun KCMS Profile Server 315 EOF 316 317 # Remove sadmind 318 inetd_remove sadmind <<EOF 319 ^[# ]*100232/10[ ]*tli 320 ^# Solstice system 321 EOF 322 323 # Things below here don't appear after Solaris 8 324 325 # Remove ufsd 326 inetd_remove ufsd <<EOF 327 ^[# ]*ufsd/1[ ]*tli 328 ^# UFS-aware service daemon 329 EOF 330 331 # Remove amiserv 332 inetd_remove amiserv <<EOF 333 ^[# ]*100146/1[ ]*tli 334 ^[# ]*100147/1[ ]*tli 335 ^# AMI Daemon 336 EOF 337 338 # Things below here don't appear after Solaris 7 339 340 # Remove kerbd 341 inetd_remove kerbd <<EOF 342 ^[# ]*kerbd/4[ ]*tli 343 ^# Kerbd Daemon 344 EOF 345 346 # Things below here don't appear after Solaris 2.6 347 348 # Remove xaudio 349 inetd_remove xaudio <<EOF 350 ^[# ]*xaudio[ ]*stream 351 EOF 352 353 # Remove CDE rpc services 354 inetd_remove cde <<EOF 355 ^[# ]*dtspc[ ]*stream 356 ^[# ]*100083/1[ ]*tli 357 ^[# ]*100068/2-[45][ ]*dgram 358 ^# Sun ToolTalk Database Server 359 EOF 360 361 # End of setup, now process the file 362 while read src dest 363 do 364 sedhdr="-f $inetsedhdr" 365 366 if [ ! -f $dest ] ; then 367 # Must be a fresh install, skip the gymnastics 368 cp $src $dest 369 else 370 inetconf=$dest 371 inetold=$dest.preupgrade 372 inettmp=/tmp/inetd.tmp.$$ 373 374 # Save existing file first 375 cp $dest $inetold 376 if [ $? -ne 0 ]; then 377 echo "Unable to create $inetold" 378 exit 1 379 fi 380 381 # if new header already there, don't strip copyright or prepend 382 # new header 383 grep inetconv $inetconf >/dev/null 2>&1 && sedhdr= && src= 384 385 # Execute the stored sed script to remove all standard stuff 386 sed $sedhdr -f $inetsed < $inetconf > $inettmp 387 if [ $? -ne 0 ]; then 388 echo "Unable to create $inettmp" 389 inetd_undo 390 exit 1 391 fi 392 393 # Now we have just the customer/3rd-party records and comments. 394 # Stick our new header on the front, and clean up all the 395 # extraneous blank comment lines left over from above. 396 cmp -s $inetconf $inettmp 397 case $? in 398 0) ;; 399 1) cat $src $inettmp | nawk ' 400 BEGIN { lastblank = 0 } 401 /^#[ \t]*$/ { 402 if (lastblank == 0) { 403 lastblank = 1 404 print 405 } 406 next 407 } 408 { lastblank = 0; print } 409 ' > $inetconf 410 if [ $? -ne 0 ]; then 411 echo "Unable to construct $inetconf" 412 inetd_undo 413 exit 1 414 fi 415 ;; 416 417 *) echo "Unable to read $inetconf or $inettmp" 418 inetd_undo 419 exit 1 420 ;; 421 esac 422 423 # Set correct permisisons 424 chmod 0644 $dest 425 fi 426 427 # Add cachefsd if not there 428 grep "^[# ]*100235/1[ ]" $dest >/dev/null 2>&1 || \ 429 cat >>$dest <<EOF 430 # 431 # CacheFS daemon. Provided only as a basis for conversion by inetconv(1M). 432 # 433 100235/1 tli rpc/ticotsord wait root /usr/lib/fs/cachefs/cachefsd cachefsd 434 EOF 435 436 done 437 438 # Clean up temp files 439 inetd_fini 440 441 exit 0 442 443