2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * Storage for common variables employed by the AFS user
16 * --------------------- Required definitions ---------------------
18 #include <afsconfig.h>
19 #include <afs/param.h>
24 #include "uss_common.h" /*Interface definitions */
25 #include <afs/kautils.h> /*MAXKTCREALMLEN & MAXKTCNAMELEN */
38 * ---------------------- Exported variables ----------------------
40 #define uss_AutoLen 300
41 #define uss_NumVars 10
43 char uss_User[uss_UserLen + 1]; /*User's account name */
44 char uss_Uid[uss_UidLen + 1]; /*User's uid */
45 char uss_Server[uss_ServerLen + 1]; /*FileServer hosting user's volume */
46 char uss_Partition[uss_PartitionLen + 1]; /*FileServer partition for above */
47 char uss_MountPoint[uss_MountPointLen + 1]; /*Mountpoint for user's volume */
48 char uss_RealName[uss_RealNameLen + 1]; /*User's full name */
49 char uss_Pwd[uss_PwdLen + 1]; /*User password */
50 char uss_PwdPath[uss_PwdPathLen + 1]; /*Curr pathname to password file */
51 char uss_PwdFormat[uss_PwdFormatLen + 1]; /*Curr password entry format */
52 char uss_RestoreDir[uss_RestoreDirLen + 1]; /*Curr directory for restore info */
53 char uss_Auto[uss_AutoLen + 1]; /*Curr choice of AUTO value */
54 char uss_Var[uss_NumVars][uss_MAX_ARG_SIZE]; /*$1, $2, ... command variables */
55 int uss_VarMax = 0; /*Largest index in above */
56 char uss_Volume[uss_VolumeLen + 1]; /*Name of user's volume */
57 afs_int32 uss_VolumeID; /*Numerical volume ID */
58 afs_int32 uss_ServerID; /*Numerical server ID */
59 afs_int32 uss_PartitionID; /*Numerical partition ID */
60 char uss_DirPool[100][uss_DirPoolLen]; /*List of all acceptable subdirs */
64 * Values saved across invocations.
66 char uss_PwdPath_Saved[uss_PwdPathLen]; /*Pathname to saved pwd file */
67 char uss_PwdFormat_Saved[uss_PwdFormatLen]; /*Saved pwd entry format */
68 char uss_RestoreDir_Saved[uss_RestoreDirLen]; /*Saved dir for restore info */
70 int uss_NumGroups = 0; /*Number of $AUTO entries */
71 int uss_SaveVolume; /*Save current user volume? */
72 int uss_SaveVolume_Saved; /*Saved value of above */
73 int uss_DryRun = 0; /*Is this a dry run? */
74 int uss_SkipKaserver = 0; /*Don't talk to kaserver */
75 int uss_Overwrite = 0; /*Overwrite user files? */
76 int uss_OverwriteThisOne; /*Overwrite on this pass? */
77 char uss_Administrator[64]; /*Name of admin account */
78 char uss_AccountCreator[MAXKTCNAMELEN]; /*Principal running this program */
79 afs_int32 uss_DesiredUID; /*Uid to assign the user */
80 afs_int32 uss_Expires; /*How long between password expires */
81 char uss_Cell[MAXKTCREALMLEN]; /*Cell in which account lives */
82 char uss_ConfDir[uss_PATH_SIZE]; /*Config directory */
83 int uss_verbose = 0; /*Are we being verbose? */
84 int uss_ignoreFlag = 0; /*Ignore yyparse errors? */
86 char uss_whoami[64]; /*Program name used */
87 int uss_syntax_err = 0; /*YACC syntax error? */
88 struct uss_subdir *uss_currentDir = NULL; /*Current directory */
92 * ----------------------- Private variables ----------------------
94 static int initDone = 0; /*Have we been initialized? */
97 /*------------------------------------------------------------------------
98 * EXPORTED uss_common_Init
101 * Set up various common uss variables, especially the saved ones.
110 * We only allow an initialization once.
114 *------------------------------------------------------------------------*/
118 { /*uss_common_Init */
120 extern int line; /*Current template line */
125 strcpy(uss_ConfDir, AFSDIR_CLIENT_ETC_DIRPATH);
126 uss_PwdPath_Saved[0] = '\0';
127 uss_PwdFormat_Saved[0] = '\0';
128 uss_RestoreDir_Saved[0] = '\0';
129 uss_SaveVolume_Saved = 0;
133 } /*uss_common_Init */
136 /*------------------------------------------------------------------------
137 * EXPORTED uss_common_Reset
140 * Resets some of the common variables to their idle or
150 * Nothing interesting.
154 *------------------------------------------------------------------------*/
158 { /*uss_common_Reset */
160 extern int line; /*Current template line */
161 int i; /*Loop variable */
166 uss_currentDir = NULL;
171 uss_Server[0] = '\0';
172 uss_Partition[0] = '\0';
173 uss_MountPoint[0] = '\0';
174 uss_RealName[0] = '\0';
175 sprintf(uss_Pwd, "%s", uss_DEFAULT_PASSWORD);
176 strcpy(uss_PwdPath, uss_PwdPath_Saved);
177 strcpy(uss_PwdFormat, uss_PwdFormat_Saved);
178 strcpy(uss_RestoreDir, uss_RestoreDir_Saved);
179 uss_SaveVolume = uss_SaveVolume_Saved;
181 for (i = 1; i < 10; i++)
182 uss_Var[i][0] = '\0';
185 * Reset the template line you think you're reading from, and
186 * remember you haven't seen any template file parsing errors
192 } /*uss_common_Reset */
195 /*------------------------------------------------------------------------
196 * EXPORTED uss_common_FieldCp
199 * Nothing interesting.
203 *------------------------------------------------------------------------*/
206 uss_common_FieldCp(a_to, a_from, a_separator, a_maxChars, a_overflowP)
213 { /*uss_common_FieldCp */
215 register int chars_read; /*Number of chars read so far */
220 * It's OK to read in the separator/null after reading a_maxChars,
221 * so we need to bump a_maxChars by one.
225 while (*a_from != a_separator && *a_from != '\0' && *a_from != '\n') {
227 if (++chars_read >= a_maxChars) {
229 * Bummer, we've overflowed. Remember the sad fact, and
230 * move the destination pointer back over the extra
231 * character. Also, skip over any garbage sitting after
232 * the characters that won't fit in to the given field.
237 printf("*** Skipping overflow char '%c'\n", *(a_from - 1));
239 while (*a_from != a_separator && *a_from != '\0'
240 && *a_from != '\n') {
242 printf("*** Skipping overflow char '%c'\n", *a_from);
245 } /*Skip over excess chars */
247 } /*Found overflow */
248 } /*Read til end of field */
251 * Make sure we return a null-terminated string.
256 * Collapse any number of blanks, should we have ended up pointing
259 if (a_separator == ' ')
260 while ((*a_from == ' ') && (*(a_from + 1) == ' '))
264 * Return the position of the next non-separator char or
265 * the position of the null, if that's what was left.
272 } /*uss_common_FieldCp */