resource.c revision 1233
830N/A * Copyright (c) 1988-91 by Patrick J. Naughton. 830N/A * Permission to use, copy, modify, and distribute this software and its 830N/A * documentation for any purpose and without fee is hereby granted, 830N/A * provided that the above copyright notice appear in all copies and that 830N/A * both that copyright notice and this permission notice appear in 830N/A * supporting documentation. 830N/A * This file is provided AS IS with no warranties of any kind. The author 830N/A * shall have no liability with respect to the infringement of copyrights, 830N/A * trade secrets or any patents by this file or any part thereof. In no 830N/A * event will the author be liable for any lost revenue or profits or 830N/A * other special, indirect and consequential damages. 830N/A * Copyright (c) 1990, 2011, Oracle and/or its affiliates. All rights reserved. 830N/A * Permission is hereby granted, free of charge, to any person obtaining a 830N/A * copy of this software and associated documentation files (the "Software"), 830N/A * to deal in the Software without restriction, including without limitation 830N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense, 830N/A * and/or sell copies of the Software, and to permit persons to whom the 830N/A * Software is furnished to do so, subject to the following conditions: 830N/A * The above copyright notice and this permission notice (including the next 830N/A * paragraph) shall be included in all copies or substantial portions of the 830N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 830N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 830N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 830N/A * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 830N/A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 830N/A * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 830N/A * DEALINGS IN THE SOFTWARE. 830N/A * resource.c - resource management for xlock, the X Window System lockscreen. 830N/A * 24-Jun-91: changed name to username. 830N/A * 06-Jun-91: Added flame mode. 830N/A * 24-May-91: Added -name and -usefirst and -resources. 830N/A * 16-May-91: Added random mode and pyro mode. 830N/A * 26-Mar-91: CheckResources: delay must be >= 0. 830N/A * 29-Oct-90: Added #include <ctype.h> for missing isupper() on some OS revs. 830N/A * moved -mode option, reordered Xrm database evaluation. 830N/A * 28-Oct-90: Added text strings. 830N/A * 26-Oct-90: Fix bug in mode specific options. 830N/A * 31-Jul-90: Fix ':' handling in parsefilepath 830N/A#
define DEF_FONT "-b&h-lucida-medium-r-normal-sans-24-*-*-*-*-*-iso8859-1" 830N/A#
define DEF_INFO "Enter password to unlock; select icon to lock." #
define DEF_TIMEOUT "30" /* secs till password entry times out */#
define DEF_BC "100" /* vectors (or whatever) per batch */#
define DEF_DELAY "200000"/* microseconds between batches */#
define DEF_NICE "10" /* xlock process nicelevel */#
define DEF_SAT "1.0" /* color ramp saturation 0->1 */ {
"-help",
"print out this message"},
{
"-resources",
"print default resource file to standard output"},
{
"-display displayname",
"X server to contact"},
{
"-name resourcename",
"class name to use for resources (default is XLock)"},
{
"-/+mono",
"turn on/off monochrome override"},
{
"-/+nolock",
"turn on/off no password required mode"},
{
"-/+remote",
"turn on/off remote host access"},
{
"-/+allowroot",
"turn on/off allow root password mode"},
{
"-/+enablesaver",
"turn on/off enable X server screen saver"},
{
"-/+allowaccess",
"turn on/off allow new clients to connect"},
{
"-/+echokeys",
"turn on/off echo '?' for each password key"},
{
"-/+usefirst",
"turn on/off using the first char typed in password"},
{
"-/+v",
"turn on/off verbose mode"},
{
"-delay usecs",
"microsecond delay between screen updates"},
{
"-batchcount num",
"number of things per batch"},
{
"-nice level",
"nice level for xlock process"},
{
"-timeout seconds",
"number of seconds before password times out"},
{
"-saturation value",
"saturation of color ramp"},
{
"-font fontname",
"font to use for password prompt"},
{
"-bg color",
"background color to use for password prompt"},
{
"-fg color",
"foreground color to use for password prompt"},
{
"-name string",
"text string to use for Name prompt"},
{
"-password string",
"text string to use for Password prompt"},
{
"-info string",
"text string to use for instructions"},
{
"-validate string",
"text string to use for validating password message"},
{
"-invalid string",
"text string to use for invalid password message"},
/* 4036289. Limit the size of string to print. */ error(
"GetResource - couldn't allocate memory");
/* 4036289, do not use stack buffer, allocate this buffer from the heap*/ /* Scan through source, expanding % strings as necessary, and passing completed paths to XrmGetFileDatabase when ':' or end of string is found. To prevent buffer overflows (bug 4483090) each time we decide to append to the string, we set appenddata to point to the data to be appended & appendsize to the size to be appended, and then do all the appending & size checking in one place at the end. }
else if (*
src ==
':') {
}
else if (*
src ==
'\0') {
/* Grow by a bit more than we need so we don't have to error(
"parsefilepath - couldn't allocate memory");
* only restrict access to other displays if we are locking and if the * Remote resource is not set. /* 1183055(rfe): xlock doesnt accept long display/host name * Get the ip address of $DISPLAY and the machine name. * If both are matching then allow to open display. * ( also check against the ip addr list returned by gethostbyname. * Otherwise, report error and exit. * display_ip contains IP address of the $DISPLAY * host_ip contains IP address of the machine_name * tmp_display contains the $DISPLAY - [:0.0 or :0] * This fix will take care of long host name and IP address form. error(
"Can't get local hostname.\n");
error(
"Can't get address information for %s.\n",
error(
"Can't get hostbyname.\n");
/* check against the list of Internet address */ /* display has been replaced tmp_display because * display will be in :0.0 format and tmp_display * get -name arg from command line so you can have different resource /* 4036289, Limit the string to print */ /* 4036289, Limit the string to print */ /* 4036289, Limit the string to print */ * if random mode, then just grab a random entry from the table /* 4036289, Limit the string to print */ /* Parse the rest of the command line */ /* the RDB is set, now query load the variables from the database */ Syntax(
"-batchcount argument must be positive.");
Syntax(
"-saturation argument must be between 0.0 and 1.0.");
Syntax(
"-delay argument must be positive.");