VBoxExtPackHelperApp.cpp revision f5e968755e8a553874d48ba15f80df71659951b8
/* $Id$ */
/** @file
* VirtualBox Main - Extension Pack Helper Application, usually set-uid-to-root.
*/
/*
* Copyright (C) 2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "include/ExtPackUtil.h"
#include <iprt/buildconfig.h>
#include <iprt/initterm.h>
#include <iprt/manifest.h>
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/** The maximum entry name length.
* Play short and safe. */
#define VBOX_EXTPACK_MAX_ENTRY_NAME_LENGTH 128
#ifdef IN_RT_R3
/* Override RTAssertShouldPanic to prevent gdb process creation. */
RTDECL(bool) RTAssertShouldPanic(void)
{
return true;
}
#endif
/**
* Handle the special standard options when these are specified after the
* command.
*
* @param ch The option character.
*/
{
switch (ch)
{
case 'h':
{
"All rights reserved.\n"
"\n"
"This NOT intended for general use, please use VBoxManage instead\n"
"or call the IExtPackManager API directly.\n"
"\n"
"Usage: %s <command> [options]\n"
"Commands:\n"
" install --base-dir <dir> --cert-dir <dir> --name <name> \\\n"
" --tarball <tarball> --tarball-fd <fd>\n"
" uninstall --base-dir <dir> --name <name>\n"
" cleanup --base-dir <dir>\n"
, RTProcShortName());
return RTEXITCODE_SUCCESS;
}
case 'V':
return RTEXITCODE_SUCCESS;
default:
}
}
/**
* Checks if the cerficiate directory is valid.
*
* @returns true if it is valid, false if it isn't.
* @param pszCertDir The certificate directory to validate.
*/
static bool IsValidCertificateDir(const char *pszCertDir)
{
/*
* Just be darn strict for now.
*/
char szCorrect[RTPATH_MAX];
if (RT_FAILURE(rc))
return false;
if (RT_FAILURE(rc))
return false;
}
/**
* Checks if the base directory is valid.
*
* @returns true if it is valid, false if it isn't.
* @param pszBaesDir The base directory to validate.
*/
static bool IsValidBaseDir(const char *pszBaseDir)
{
/*
* Just be darn strict for now.
*/
char szCorrect[RTPATH_MAX];
if (RT_FAILURE(rc))
return false;
if (RT_FAILURE(rc))
return false;
}
/**
* Cleans up a temporary extension pack directory.
*
* This is used by 'uninstall', 'cleanup' and in the failure path of 'install'.
*
* @returns The program exit code.
* @param pszDir The directory to clean up. The caller is
* responsible for making sure this is valid.
* @param fTemporary Whether this is a temporary install directory or
* not.
*/
{
/** @todo May have to undo 555 modes here later. */
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE,
"Failed to delete the %sextension pack directory: %Rrc ('%s')",
return RTEXITCODE_SUCCESS;
}
/**
* Rewinds the tarball file handle and creates a gunzip | tar chain that
* results in a filesystem stream.
*
* @returns success or failure, message displayed on failure.
* @param hTarballFile The handle to the tarball file.
* @param phTarFss Where to return the filesystem stream handle.
*/
{
/*
* Rewind the file and set up a VFS chain for it.
*/
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed seeking to the start of the tarball: %Rrc\n", rc);
rc = RTVfsIoStrmFromRTFile(hTarballFile, RTFILE_O_READ | RTFILE_O_DENY_WRITE | RTFILE_O_OPEN, true /*fLeaveOpen*/,
&hTarballIos);
if (RT_FAILURE(rc))
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
return RTEXITCODE_SUCCESS;
}
}
else
return RTEXITCODE_FAILURE;
}
/**
* Sets the permissions of the temporary extension pack directory just before
* renaming it.
*
* By default the temporary directory is only accessible by root, this function
* will make it world readable and browseable.
*
* @returns The program exit code.
* @param pszDir The temporary extension pack directory.
*/
{
RTMsgInfo("Setting permissions...");
#if !defined(RT_OS_WINDOWS)
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to set directory permissions: %Rrc ('%s')", rc, pszDir);
#else
/** @todo */
#endif
return RTEXITCODE_SUCCESS;
}
/**
* Verifies the manifest and its signature.
*
* @returns Program exit code, failure with message.
* @param hManifestFile The xml from the extension pack.
* @param pszExtPackName The expected extension pack name.
*/
{
/** @todo implement XML verification. */
return RTEXITCODE_SUCCESS;
}
/**
* Verifies the manifest and its signature.
*
* @returns Program exit code, failure with message.
* @param hOurManifest The manifest we compiled.
* @param hManifestFile The manifest file in the extension pack.
* @param hSignatureFile The manifest signature file.
*/
static RTEXITCODE VerifyManifestAndSignature(RTMANIFEST hOurManifest, RTVFSFILE hManifestFile, RTVFSFILE hSignatureFile)
{
/*
* Read the manifest from the extension pack.
*/
if (RT_FAILURE(rc))
if (RT_FAILURE(rc))
if (RT_SUCCESS(rc))
{
/*
* Compare the manifests.
*/
static const char *s_apszIgnoreEntries[] =
{
};
char szError[RTPATH_MAX];
RTMANIFEST_EQUALS_IGN_MISSING_ATTRS /*fFlags*/,
if (RT_SUCCESS(rc))
{
/*
* Validate the manifest file signature.
*/
/** @todo implement signature stuff */
}
else
#if 0
#endif
}
else
}
/**
* Validates a name in an extension pack.
*
* We restrict the charset to try make sure the extension pack can be unpacked
* on all file systems.
*
* @returns Program exit code, failure with message.
* @param pszName The name to validate.
*/
{
if (RTPathStartsWithRoot(pszName))
int ch;
{
/* Character set restrictions. */
{
pszErr = "Only 7-bit ASCII allowed";
break;
}
{
pszErr = "No control characters are not allowed";
break;
}
if (ch == '\\')
{
pszErr = "Only backward slashes are not allowed";
break;
}
{
pszErr = "The characters ', \", :, ;, *, ?, |, [, ], <, >, (, ), { and } are not allowed";
break;
}
/* Take the simple way out and ban all ".." sequences. */
if ( ch == '.'
{
pszErr = "Double dot sequence are not allowed";
break;
}
/* Keep the tree shallow or the hardening checks will fail. */
{
pszErr = "Too long";
break;
}
/* advance */
psz++;
}
if (pszErr)
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Bad member name '%s' (pos %zu): %s", pszName, (size_t)(psz - pszName), pszErr);
return RTEXITCODE_SUCCESS;
}
/**
* Validates a file in an extension pack.
*
* @returns Program exit code, failure with message.
* @param pszName The name of the file.
* @param hVfsObj The VFS object.
*/
{
if (rcExit == RTEXITCODE_SUCCESS)
{
if (RT_SUCCESS(rc))
{
"The alleged file '%s' has a mode mask saying differently (%RTfmode)",
}
else
}
return rcExit;
}
/**
* Validates a directory in an extension pack.
*
* @returns Program exit code, failure with message.
* @param pszName The name of the directory.
* @param hVfsObj The VFS object.
*/
{
if (rcExit == RTEXITCODE_SUCCESS)
{
if (RT_SUCCESS(rc))
{
"The alleged directory '%s' has a mode mask saying differently (%RTfmode)",
}
else
}
return rcExit;
}
/**
* Validates a member of an extension pack.
*
* @returns Program exit code, failure with message.
* @param pszName The name of the directory.
* @param enmType The object type.
* @param hVfsObj The VFS object.
*/
static RTEXITCODE ValidateMemberOfExtPack(const char *pszName, RTVFSOBJTYPE enmType, RTVFSOBJ hVfsObj)
{
if ( enmType == RTVFSOBJTYPE_FILE
|| enmType == RTVFSOBJTYPE_IO_STREAM)
else if ( enmType == RTVFSOBJTYPE_DIR
|| enmType == RTVFSOBJTYPE_BASE)
else
rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "'%s' is not a file or directory (enmType=%d)", pszName, enmType);
return rcExit;
}
/**
* Validates the extension pack tarball prior to unpacking.
*
* Operations performed:
* - Hardening checks.
*
* @returns The program exit code.
* @param pszDir The directory where the extension pack has been
* unpacked.
* @param pszExtPackName The expected extension pack name.
* @param pszTarball The name of the tarball in case we have to
* complain about something.
*/
static RTEXITCODE ValidateUnpackedExtPack(const char *pszDir, const char *pszTarball, const char *pszExtPackName)
{
RTMsgInfo("Validating unpacked extension pack...");
int rc = SUPR3HardenedVerifyDir(pszDir, true /*fRecursive*/, true /*fCheckFiles*/, szErr, sizeof(szErr));
if (RT_FAILURE(rc))
return RTEXITCODE_SUCCESS;
}
/**
* Unpacks a directory from an extension pack tarball.
*
* @returns Program exit code, failure with message.
* @param pszDstDirName The name of the unpacked directory.
* @param hVfsObj The source object for the directory.
*/
{
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to create directory '%s': %Rrc", pszDstDirName, rc);
/** @todo Ownership tricks on windows? */
return RTEXITCODE_SUCCESS;
}
/**
* Unpacks a file from an extension pack tarball.
*
* @returns Program exit code, failure with message.
* @param pszName The name in the tarball.
* @param pszDstFilename The name of the unpacked file.
* @param hVfsIosSrc The source stream for the file.
* @param hUnpackManifest The manifest to add the file digest to.
*/
{
/*
* Query the object info, we'll need it for buffer sizing as well as
* setting the file mode.
*/
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTVfsIoStrmQueryInfo failed with %Rrc on '%s'", rc, pszDstFilename);
/*
* Create the file.
*/
uint32_t fFlags = RTFILE_O_WRITE | RTFILE_O_DENY_ALL | RTFILE_O_CREATE | (0600 << RTFILE_O_CREATE_MODE_SHIFT);
if (RT_FAILURE(rc))
/*
* Create a I/O stream for the destination file, stack a manifest entry
* creator on top of it.
*/
if (RT_SUCCESS(rc))
{
false /*fReadOrWrite*/, &hVfsIosDst);
if (RT_SUCCESS(rc))
{
/*
* Pump the data thru.
*/
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
/*
* Set the mode mask.
*/
/** @todo Windows needs to do more here, I think. */
if (RT_SUCCESS(rc))
{
return RTEXITCODE_SUCCESS;
}
RTMsgError("Failed to set the mode of '%s' to %RTfmode: %Rrc", pszDstFilename, ObjInfo.Attr.fMode, rc);
}
else
}
else
}
else
}
else
return RTEXITCODE_FAILURE;
}
/**
* Unpacks the extension pack into the specified directory.
*
* This will apply ownership and permission changes to all the content, the
* exception is @a pszDirDst which will be handled by SetExtPackPermissions.
*
* @returns The program exit code.
* @param hTarballFile The tarball to unpack.
* @param pszDirDst Where to unpack it.
* @param hValidManifest The manifest we've validated.
* @param pszTarball The name of the tarball in case we have to
* complain about something.
*/
static RTEXITCODE UnpackExtPack(RTFILE hTarballFile, const char *pszDirDst, RTMANIFEST hValidManifest,
const char *pszTarball)
{
/*
* Set up the destination path.
*/
char szDstPath[RTPATH_MAX];
int rc = RTPathAbs(pszDirDst, szDstPath, sizeof(szDstPath) - VBOX_EXTPACK_MAX_ENTRY_NAME_LENGTH - 2);
if (RT_FAILURE(rc))
/*
* Open the tar.gz filesystem stream and set up an manifest in-memory file.
*/
if (rcExit != RTEXITCODE_SUCCESS)
return rcExit;
if (RT_SUCCESS(rc))
{
/*
* Process the tarball (would be nice to move this to a function).
*/
for (;;)
{
/*
* Get the next stream object.
*/
char *pszName;
if (RT_FAILURE(rc))
{
break;
}
/*
* Check the type & name validity then unpack it.
*/
if (rcExit == RTEXITCODE_SUCCESS)
{
if (RT_SUCCESS(rc))
{
if ( enmType == RTVFSOBJTYPE_FILE
|| enmType == RTVFSOBJTYPE_IO_STREAM)
{
}
}
else
}
/*
* Clean up and break out on failure.
*/
if (rcExit != RTEXITCODE_SUCCESS)
break;
}
/*
* Check that what we just extracted matches the already verified
* manifest.
*/
if (rcExit == RTEXITCODE_SUCCESS)
{
char szError[RTPATH_MAX];
rc = RTManifestEqualsEx(hUnpackManifest, hValidManifest, NULL /*papszIgnoreEntries*/, NULL /*papszIgnoreAttr*/,
if (RT_SUCCESS(rc))
else
}
#if 0
#endif
}
return rcExit;
}
/**
* Validates the extension pack tarball prior to unpacking.
*
* Operations performed:
* - Mandatory files.
* - Manifest check.
* - Manifest seal check.
* - XML check, match name.
*
* @returns The program exit code.
* @param hTarballFile The handle to open the @a pszTarball file.
* @param pszExtPackName The name of the extension pack name.
* @param pszTarball The name of the tarball in case we have to
* complain about something.
* @param phValidManifest Where to return the handle to fully validated
* the manifest for the extension pack. This
* includes all files.
*
* @todo This function is a bit too long and should be split up if possible.
*/
static RTEXITCODE ValidateExtPackTarball(RTFILE hTarballFile, const char *pszExtPackName, const char *pszTarball,
{
/*
* Open the tar.gz filesystem stream and set up an manifest in-memory file.
*/
if (rcExit != RTEXITCODE_SUCCESS)
return rcExit;
if (RT_SUCCESS(rc))
{
/*
* Process the tarball (would be nice to move this to a function).
*/
for (;;)
{
/*
* Get the next stream object.
*/
char *pszName;
if (RT_FAILURE(rc))
{
break;
}
/*
* Check the type & name validity.
*/
if (rcExit == RTEXITCODE_SUCCESS)
{
/*
* Check if this is one of the standard files.
*/
else
if (phVfsFile)
{
/*
* Make sure it's a file and that it isn't too large.
*/
if (*phVfsFile != NIL_RTVFSFILE)
else
{
if (RT_SUCCESS(rc))
{
"Standard member '%s' is too large: %'RU64 bytes (max 1 MB)",
else
{
/*
* Make an in memory copy of the stream.
*/
if (RT_SUCCESS(rc))
{
/*
* To simplify the code below, replace
* hVfsObj with the memorized file.
*/
}
else
}
}
else
}
}
}
/*
* Add any I/O stream to the manifest
*/
if ( rcExit == RTEXITCODE_SUCCESS
&& ( enmType == RTVFSOBJTYPE_FILE
|| enmType == RTVFSOBJTYPE_IO_STREAM))
{
rc = RTManifestEntryAddIoStream(hOurManifest, hVfsIos, pszAdjName, RTMANIFEST_ATTR_SIZE | RTMANIFEST_ATTR_SHA256);
if (RT_FAILURE(rc))
rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "RTManifestEntryAddIoStream failed on '%s': %Rrc", pszAdjName, rc);
}
/*
* Clean up and break out on failure.
*/
if (rcExit != RTEXITCODE_SUCCESS)
break;
}
/*
* If we've successfully processed the tarball, verify that the
* mandatory files are present.
*/
if (rcExit == RTEXITCODE_SUCCESS)
{
if (hXmlFile == NIL_RTVFSFILE)
rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Mandator file '%s' is missing", VBOX_EXTPACK_DESCRIPTION_NAME);
if (hManifestFile == NIL_RTVFSFILE)
rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Mandator file '%s' is missing", VBOX_EXTPACK_MANIFEST_NAME);
if (hSignatureFile == NIL_RTVFSFILE)
rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Mandator file '%s' is missing", VBOX_EXTPACK_SIGNATURE_NAME);
}
/*
* Check the manifest and it's signature.
*/
if (rcExit == RTEXITCODE_SUCCESS)
/*
* Check the XML.
*/
if (rcExit == RTEXITCODE_SUCCESS)
/*
* Release objects and stuff.
*/
if (rcExit == RTEXITCODE_SUCCESS)
else
}
return rcExit;
}
/**
* The 2nd part of the installation process.
*
* @returns The program exit code.
* @param pszBaseDir The base directory.
* @param pszCertDir The certificat directory.
* @param pszTarball The tarball name.
* @param hTarballFile The handle to open the @a pszTarball file.
* @param hTarballFileOpt The tarball file handle (optional).
* @param pszName The extension pack name.
*/
static RTEXITCODE DoInstall2(const char *pszBaseDir, const char *pszCertDir, const char *pszTarball,
{
/*
* Do some basic validation of the tarball file.
*/
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTFileQueryInfo failed with %Rrc on '%s'", rc, pszTarball);
if (hTarballFileOpt != NIL_RTFILE)
{
if (RT_FAILURE(rc))
}
/*
* Construct the paths to the two directories we'll be using.
*/
char szFinalPath[RTPATH_MAX];
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE,
"Failed to construct the path to the final extension pack directory: %Rrc", rc);
char szTmpPath[RTPATH_MAX];
if (RT_SUCCESS(rc))
{
RTStrPrintf(&szTmpPath[cchTmpPath], sizeof(szTmpPath) - cchTmpPath, "-_-inst-%u", (uint32_t)RTProcSelf());
}
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE,
"Failed to construct the path to the temporary extension pack directory: %Rrc", rc);
/*
* Check that they don't exist at this point in time.
*/
return RTMsgErrorExit(RTEXITCODE_FAILURE, "The extension pack is already installed. You must uninstall the old one first.");
if (RT_SUCCESS(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE,
"Found non-directory file system object where the extension pack would be installed ('%s')",
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Unexpected RTPathQueryInfoEx status code %Rrc for '%s'", rc, szFinalPath);
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Unexpected RTPathQueryInfoEx status code %Rrc for '%s'", rc, szFinalPath);
/*
* Create the temporary directory and prepare the extension pack within it.
* If all checks out correctly, rename it to the final directory.
*/
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to create temporary directory: %Rrc ('%s')", rc, szTmpPath);
if (rcExit == RTEXITCODE_SUCCESS)
if (rcExit == RTEXITCODE_SUCCESS)
if (rcExit == RTEXITCODE_SUCCESS)
if (rcExit == RTEXITCODE_SUCCESS)
{
if (RT_SUCCESS(rc))
else
"Failed to rename the temporary directory to the final one: %Rrc ('%s' -> '%s')",
}
/*
* Clean up the temporary directory on failure.
*/
if (rcExit != RTEXITCODE_SUCCESS)
return rcExit;
}
/**
* Implements the 'install' command.
*
* @returns The program exit code.
* @param argc The number of program arguments.
* @param argv The program arguments.
*/
{
/*
* Parse the parameters.
*
* Note! The --base-dir and --cert-dir are only for checking that the
* caller and this help applications have the same idea of where
* things are. Likewise, the --name is for verifying assumptions
* the caller made about the name. The optional --tarball-fd option
* is just for easing the paranoia on the user side.
*/
static const RTGETOPTDEF s_aOptions[] =
{
};
if (RT_FAILURE(rc))
const char *pszBaseDir = NULL;
const char *pszCertDir = NULL;
const char *pszTarball = NULL;
int ch;
{
switch (ch)
{
case 'b':
if (pszBaseDir)
if (!IsValidBaseDir(pszBaseDir))
break;
case 'c':
if (pszCertDir)
if (!IsValidCertificateDir(pszCertDir))
break;
case 'n':
if (pszName)
if (!VBoxExtPackIsValidName(pszName))
break;
case 't':
if (pszTarball)
break;
case 'd':
{
if (hTarballFileOpt != NIL_RTFILE)
return RTMsgErrorExit(RTEXITCODE_SYNTAX, "The --tarball-fd value is out of range: %#RX64", ValueUnion.u64);
if (RT_FAILURE(rc))
break;
}
case 'h':
case 'V':
return DoStandardOption(ch);
default:
}
}
if (!pszName)
if (!pszBaseDir)
if (!pszCertDir)
if (!pszTarball)
/*
* Ok, down to business.
*/
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to open the extension pack tarball: %Rrc ('%s')", rc, pszTarball);
RTEXITCODE rcExit = DoInstall2(pszBaseDir, pszCertDir, pszTarball, hTarballFile, hTarballFileOpt, pszName);
return rcExit;
}
/**
* Implements the 'uninstall' command.
*
* @returns The program exit code.
* @param argc The number of program arguments.
* @param argv The program arguments.
*/
{
/*
* Parse the parameters.
*
* Note! The --base-dir is only for checking that the caller and this help
* applications have the same idea of where things are.
*/
static const RTGETOPTDEF s_aOptions[] =
{
};
if (RT_FAILURE(rc))
const char *pszBaseDir = NULL;
int ch;
{
switch (ch)
{
case 'b':
if (pszBaseDir)
if (!IsValidBaseDir(pszBaseDir))
break;
case 'n':
if (pszName)
if (!VBoxExtPackIsValidName(pszName))
break;
case 'h':
case 'V':
return DoStandardOption(ch);
default:
}
}
if (!pszName)
if (!pszBaseDir)
/*
* Ok, down to business.
*/
/* Check that it exists. */
char szExtPackDir[RTPATH_MAX];
if (RT_FAILURE(rc))
if (!RTDirExists(szExtPackDir))
{
RTMsgInfo("Extension pack not installed. Nothing to do.");
return RTEXITCODE_SUCCESS;
}
/* Rename the extension pack directory before deleting it to prevent new
VM processes from picking it up. */
char szExtPackUnInstDir[RTPATH_MAX];
if (RT_SUCCESS(rc))
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to construct temporary extension pack path: %Rrc", rc);
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to rename the extension pack directory: %Rrc", rc);
/* Recursively delete the directory content. */
if (rcExit == RTEXITCODE_SUCCESS)
return rcExit;
}
/**
* Implements the 'cleanup' command.
*
* @returns The program exit code.
* @param argc The number of program arguments.
* @param argv The program arguments.
*/
{
/*
* Parse the parameters.
*
* Note! The --base-dir is only for checking that the caller and this help
* applications have the same idea of where things are.
*/
static const RTGETOPTDEF s_aOptions[] =
{
};
if (RT_FAILURE(rc))
const char *pszBaseDir = NULL;
int ch;
{
switch (ch)
{
case 'b':
if (pszBaseDir)
if (!IsValidBaseDir(pszBaseDir))
break;
case 'h':
case 'V':
return DoStandardOption(ch);
default:
}
}
if (!pszBaseDir)
/*
* Ok, down to business.
*/
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed open the base directory: %Rrc ('%s')", rc, pszBaseDir);
for (;;)
{
if (RT_FAILURE(rc))
{
if (rc != VERR_NO_MORE_FILES)
break;
}
{
char szPath[RTPATH_MAX];
if (RT_SUCCESS(rc))
{
if (rcExit2 == RTEXITCODE_SUCCESS)
else if (rcExit == RTEXITCODE_SUCCESS)
}
else
rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "RTPathJoin failed with %Rrc for '%s'", rc, Entry.szName);
cCleaned++;
}
}
if (!cCleaned)
RTMsgInfo("Nothing to clean.");
return rcExit;
}
{
/*
* Initialize IPRT and check that we're correctly installed.
*/
if (RT_FAILURE(rc))
return RTMsgInitFailure(rc);
char szErr[2048];
if (RT_FAILURE(rc))
/*
* Parse the top level arguments until we find a command.
*/
static const RTGETOPTDEF s_aOptions[] =
{
#define CMD_INSTALL 1000
#define CMD_UNINSTALL 1001
#define CMD_CLEANUP 1002
};
if (RT_FAILURE(rc))
for (;;)
{
switch (ch)
{
case 0:
case CMD_INSTALL:
case CMD_UNINSTALL:
case CMD_CLEANUP:
case 'h':
case 'V':
return DoStandardOption(ch);
default:
}
/* not currently reached */
}
/* not reached */
}