Previous     Contents     Index     Next     
Setup Util Programmer's Guide



Chapter 22   Ux-util.h Library Reference


This chapter describes ux-util.h, the library containing various UNIX utility functions used during installation. It contains the following sections:

  • Definitions

  • C Functions

  • C++ Functions



Definitions


General

extern const char *INSTALL_TYPE;

extern const char *EXPRESS_TYPE;

extern const char *TYPICAL_TYPE;

extern const char *CUSTOM_TYPE;


Package Type
typedef enum {Normal=0, Update=1, Patch=2} PackageType;


Install Log Error Levels
extern const char *FATAL;

extern const char *INFO;

extern const char *WARN;

extern const char *START;

extern const char *SUCCESS;



C Functions

These are for those who use C as well as C++.


Common Functions


getDefaultLdapInfo
Given a server root, get the default LDAP information.

extern void getDefaultLdapInfo (const char *sroot, char **ldapURL,
   char **ldapUser, char **installDN);


Utilities

Refer to the C++ sections for more explanations

extern char *guessHostname();

extern char *guessDomain();

extern int guessPort();

extern Bool portAvailable(int port);

extern int availUser(const char *user);

extern int availGroup(const char *user, const char *group);

extern char *getDefaultHostName(const char *sroot);

extern char *getDefaultUser(const char *sroot);

extern char *getDefaultGroup(const char *sroot);

extern char *getSysVersion();

extern char *getCurrentDir(void);

extern Bool dirWritable(const char *dirName);

extern int createDirectory(const char *dirName, int mode);

extern Bool fileExists(const char *fileName);

extern Bool dirExists(const char *dirName);

extern Bool isServerRoot(const char *directoryName);

extern Bool isLegacyServerRoot (const char *dirName);

extern int execProgram(const char *program, const char *where);


Silent Installation Log


InstallLog Definition
typedef void * InstallLog;


createInstallLog
Creates a silent installation logfile.

InstallLog *createInstallLog(const char *fileName);


logMessage
Logs a string to the logfile.

void logMessage(InstallLog *, const char *level, const char *who,
   const char *msg, ...);



C++ Functions


Utilities


InstUtil
Class definition for C++ installation utilities.

class InstUtil


InstUtil::guessHostname
Try to guess the fully qualified domain name (FQDN) of this host.

static NSString guessHostname();


InstUtil::guessDomain
Try to guess the domain name portion of this host.

static NSString guessDomain();


InstUtil::guessPort
Randomly select an available port.

static int guessPort();


InstUtil::portAvailable
Determine whether the given port is available

static Bool portAvailable(int port);


InstUtil::availUser
Given a UNIX user ID, determine whether the user is available. Takes the following input:

  • UNIX user ID

Returns one of the following:

  •  0: user is okay

  • -1: user is not found

  • -2: chown failed

static int availUser(const char *user);


InstUtil::availGroup
Given a user ID and a group, determine whether the combination is OK.

Returns one of the following:

  •  0: group is OK

  • -1: user not found

  • -2: group not found

  • -3: user not in group

  • -4: chown on file with user/group failed

static int availGroup (const char *user, const char *group);


InstUtil::getSysVersion
Gets the version of the current OS, in the form of OSversion.release For example, SunOS5.5.

static NSString getSysVersion();


InstUtil::getDefaultHostName
Given a server root, gets the configured FQDN of this machine.

static NSString getDefaultHostName(const char *sroot);


InstUtil::getHostIpAddress
Given a host name, gets the associated IP address.

static NSString getHostIpAddress(const char *hostName);


InstUtil::getDefaultUser
Given a server root, gets the configured UNIX user ID. This ID is used to run servers.

static NSString getDefaultUser(const char *sroot);


InstUtil::getDefaultGroup
Given a server root, gets the configured UNIX group. This group is used to run servers.

static NSString getDefaultGroup (const char *sroot);


InstUtil::getAdmPwd
Given a server root, gets the Administrator's password. This password is used to authenticate to the Directory Server. Takes the following inputs:

  • server root

Has the following outputs:

  • Administrator's password

Returns the following:

  • Administrator's password (allocated)

static NSString getAdmPwd(const char *sroot);


InstUtil::isSelfRootUser()
Checks if current login ID is root of the running process.

static Bool isSelfRootUser();


InstUtil::getSelfUserID()
Gets the (effective) login ID of the running process.

static NSString getSelfUserID();


InstUtil::getSelfGroupID()
Gets the (effective) group ID of the running process.

static NSString getSelfGroupID();


InstUtil::getCurrentDir
Gets the current working directory.

static NSString getCurrentDir(void);


InstUtil::dirWritable
Given a full path of a directory, check that the directory exists and is writable.

static Bool dirWritable(const char *dirName);


InstUtil::dirName
Gets the directory portion of a filename.

static NSString dirName(const char *path);


InstUtil::fileName
Gets the file portion of a filename.

static NSString fileName(const char *path);


InstUtil::createDirectory
Given a full path of a directory, creates it.

static int createDirectory(const char *dirName, int mode);


InstUtil::fileExists
Determines if the given filename exists. If only a directory is given, fileExists determines whether it exists.

static Bool fileExists(const char *fileName);


InstUtil::dirExists
Determines if the given directory exists. If a filename is also given, dirExists only determines whether the directory exists.

static Bool dirExists(const char *dirName);


InstUtil::copyFile
Copies a file.

static int copyFile(const char *dest, const char *src);


InstUtil::dirEmpty
Determines whether a directory is empty.

static Bool dirEmpty(const char *dirName);


InstUtil::isServerRoot
Tries to guess whether the given directory is a 4.0 server root.

static Bool isServerRoot(const char *directory);


InstUtil::isLegacyServerRoot
Detects whether the directory is a pre-4.0 server root.

static Bool isLegacyServerRoot(const char *directory);


InstUtil::execProgram
Executes the given program. Takes the following inputs:

  • program: The program to execute.

  • where: Directory to go to before executing the program.

execProgram will return to the current directory after execution.

static int execProgram(const char *program, const char *where = 0);


Previous     Contents     Index     Next     
Copyright (C) 2005 Red Hat, Inc. All rights reserved.
This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/

Last Updated September 21, 2001