Trusted Solaris Developer's Guide

Get Attributes from Adjunct File

The vfstab_adjunct(4) file contains remote mount points and their related security information. This file is set up and maintained by the system administrator so that file systems mounted to local workstations from remote workstations have the correct security attributes.

This example retrieves and displays lines from vfstab_adjunct(4). The getvfsaent(3TSOL) routine first reads the top line of the file and with each subsequent call reads the next lines one-by-one. The getvfsaent(3TSOL) routine reads the line for the mount point specified by the input file.


Note -

Be sure to include stdio.h as shown in the example code below.


#include <stdio.h>
#include <tsol/vfstab_adjunct.h>

main()
{
	struct vfsaent *entry;
	char *vfsfile = "/etc/security/tsol/vfstab_adjunct";
	char *file = "/shark/doc";
	int retval;
	FILE *fp;

	fp = fopen(vfsfile, "r");
	if (fp == NULL) {
 		printf("Can't open %s\n", vfsfile);
 		exit(1);
	}

/* Step through file line-by-line. */
	retval = getvfsaent(fp, &entry);
	if (retval == 0) {
 		printf("Mount Point is %s \n Security Info is %s\n",
 		entry->vfsa_fsname, entry->vfsa_attr);
 		free(entry);
	}
	else
		 printf("No entries!\n");

	fseek(fp, 0, 0);

/* Retrieve specific mount point. */
	retval = getvfsafile(fp, &entry, file);
	if (retval == 0) {
		 printf("Mount Point is %s \nSecurity Info is %s\n",
		 entry->vfsa_fsname, entry->vfsa_attr);
		 free(entry);
	}
	else
		 printf("Mount point not found.\n");
	fclose(fp);
}

The printf statements print the following. There is only one entry in this vfstab_adjunct file for the /opt/SUNWspro mount point:


Mount Point is /opt/SUNWspro
Security Info is slabel=[C]:allowed all
Mount Point not found