Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1321
  • Last Modified:

Limit Unix find command to certain level

I am using the Solaris Security Toolkit to harden my Unix server. However, one of the hardening script "print-rhosts.fin" takes between 4 -20 minutes to finish. This script is to capture all the ".hiosts" and "hosts.equiv" on the system. The main action within the script is the "find" command as:

find ${JASS_ROOT_DIR} ! -local -prune -o ( -name .rhosts -o -name hosts.equiv ) -ls

I think that .hosts and hosts.equiv most likley exist only at 2nd level from the root directoy such as /etc/.hosts and /etc/hosts.equiv.

So to reduce the time runing this script, I want to customize it. Is there a way to improve the find command so that it only search down maximum to the 2nd level. I know Linux has a option "-maxdept". Not sure Solaris has something equivalent. Please help!
0
gs_kanata
Asked:
gs_kanata
  • 2
1 Solution
 
ghostdog74Commented:
change ${JASS_ROOT_DIR}  to /etc/
0
 
omarfaridCommented:
what about users' home directories? they are usually at /export/home/username
0
 
omarfaridCommented:
what about users' home directories? they are usually at /export/home/username? if it is /etc dir only then no need for the find command
0
 
ifreqCommented:
GNU find can do this with "-maxdepth 1", but Solaris find can't. To get the same functionality for Solaris find, you can use this hack: find /some/path/. \( -type d -a \! -name . -prune \) -o -type f -print

That is, first prune all directories that aren't named ".", then print the names of the remaining files. It's important that the path be "/some/path/." instead of "/some/path", because that's what enables special treatment for the top level directory.
0

Featured Post

Who's Defending Your Organization from Threats?

Protecting against advanced threats requires an IT dream team – a well-oiled machine of people and solutions working together to defend your organization. Download our resource kit today to learn more about the tools you need to build you IT Dream Team!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now