mads
mads

Reputation: 507

How to scan for SUID files in root using Java and access its properties?

I'm a newbie to UNIX systems. I'm being tasked with finding a SUID file in the root directory and access its file properties to get some things done.

Is there anyway I can write a Java based application to search for files with Sticky bit and access their properties (file permissions/creation date etc.)?

** I have been asked not to use 'find' commands in UNIX for this purpose.

Please help.

Upvotes: 2

Views: 565

Answers (1)

Jean-Baptiste Yunès
Jean-Baptiste Yunès

Reputation: 36441

From Interface PosixFileAttributeView documentation:

The permissions attribute is a set of access permissions. This file attribute view provides access to the nine permission defined by the PosixFilePermission class. These nine permission bits determine the read, write, and execute access for the file owner, group, and others (others meaning identities other than the owner and members of the group). Some operating systems and file systems may provide additional permission bits but access to these other bits is not defined by this class in this release.

Means that you can't actually access these bits (setuid and setgid) in Java. Remember that Java is OS agnostic, and such permissions are POSIX specific.

Upvotes: 1

Related Questions