30 #define _FILE_OFFSET_BITS 64
32 #include <sys/types.h>
62 #define MAXROOTURLLEN 1024
64 #define nXrdConnPerUsr 8;
75 strcpy(newurl, oldurl);
89 strcpy(newurl, oldurl);
99 if (netAddr.
Set(ipaddr,0) || !(theName = netAddr.
Name())) theName = ipaddr;
100 return strdup(theName);
110 if (!adm.
isOK() || !(uVec = adm.
FanOut(rval)))
return -1;
112 if (rval > nnodes) rval = -1;
113 else for (i = 0; i < rval; i++)
140 char *life = strdup(urlcachelife);
143 if (life == NULL)
return;
146 if (! isdigit(life[len-1]))
151 sscanf(life,
"%d", &t);
179 currtime = time(NULL);
198 for (i = 0; i < nurls; i++)
214 const char *hName, *hNend, *hPort, *hPend;
215 char *url, *rc, *hostip, hsep;
227 hostip[hNend-hostip] = 0;
228 hostip[hPend-hostip] = 0;
229 if (uAddr.
Set(hName,0) || !(netName = uAddr.
Name()))
230 {hostip[hNend-hostip] = hsep;
269 for (i = 0; i < nurls; i++) free(turls[i]);
276 char *hostlist, *p1, *p2;
283 syslog(LOG_INFO,
"INFO: use the following %d data servers :", i);
285 p2 = strchr(p1,
'\n');
289 syslog(LOG_INFO,
" %s", p1);
291 p2 = strchr(p1,
'\n');
298 static int OneTimeInitDone = 0;
302 if (OneTimeInitDone)
return;
313 if (getenv(
"XROOTDFS_SECMOD") != NULL && !strcmp(getenv(
"XROOTDFS_SECMOD"),
"sss"))
316 openlog(
"XrootdFS", LOG_ODELAY | LOG_PID, LOG_DAEMON);
325 if (getenv(
"XROOTDFS_NWORKERS") != NULL)
343 const char alpha[] =
"0123456789abcdefghijklmn";
346 memcpy(d24+1, tmp, 8);
353 unsigned int r = d % 24;
355 if ((d - r) != 0)
decTo24((d-r)/24, d24);
360 char *d24 = (
char*) malloc(9);
377 setenv(
"XrdSecPROTOCOL",
"sss", 1);
382 struct passwd pw, *pwp;
383 struct group gr, *grp;
384 char user_num[9], *pwbuf, *grbuf, *tmp;
385 static size_t pwbuflen = 0;
386 static size_t grbuflen = 0;
388 if (pwbuflen == 0) pwbuflen = sysconf(_SC_GETPW_R_SIZE_MAX);
389 if (grbuflen == 0) grbuflen = sysconf(_SC_GETGR_R_SIZE_MAX);
393 tmp =
ntoa24((
unsigned int)user_uid);
394 memcpy(user_num, tmp, 9);
402 user_num[strlen(user_num)] = *
id + 48;
405 user_num[strlen(user_num)] = 48;
409 pwbuf = (
char*) malloc(pwbuflen);
410 getpwuid_r(user_uid, &pw, pwbuf, pwbuflen, &pwp);
411 grbuf = (
char*) malloc(grbuflen);
412 getgrgid_r(user_gid, &gr, grbuf, grbuflen, &grp);
414 XrdFfsMiscUent.
name = pw.pw_name;
415 XrdFfsMiscUent.
grps = gr.gr_name;
416 XrdFfsMiscUent.
uid = user_uid;
417 XrdFfsMiscUent.
gid = user_gid;
433 memcpy(user_num, tmp, 9);
435 if (
id == NULL) user_num[strlen(user_num)] = 48;
436 else user_num[strlen(user_num)] = *
id + 48;
439 strncat(nurl,
"root://", 8);
440 strncat(nurl, user_num, 9);
441 strncat(nurl,
"@", 2);
void XrdFfsDent_cache_init()
void XrdFfsMisc_set_Urlcachelife(const char *urlcachelife)
void XrdFfsMisc_logging_url_cache(const char *url)
void XrdFfsMisc_xrd_init(const char *rdrurl, const char *urlcachelife, int startQueue)
char * XrdFfsMiscUrlcache[XrdFfs_MAX_NUM_NODES]
void XrdFfsMisc_xrd_secsss_init()
pthread_mutex_t XrdFfsMiscUrlcache_mutex
int XrdFfsMiscNcachedurls
int XrdFfsMisc_get_list_of_data_servers(char *list)
char * ntoa24(unsigned int d)
void decTo24(unsigned int d, char *d24)
char XrdFfsMisc_get_current_url(const char *oldurl, char *newurl)
void XrdFfsMisc_xrd_secsss_register(uid_t user_uid, gid_t user_gid, int *id)
char * XrdFfsMisc_getNameByAddr(char *ipaddr)
int XrdFfsMisc_get_number_of_data_servers()
void XrdFfsMisc_xrd_secsss_editurl(char *url, uid_t user_uid, int *id)
time_t XrdFfsMiscUrlcachetime
XrdSecsssID * XrdFfsMiscSssid
int XrdFfsMisc_get_all_urls(const char *oldurl, char **newurls, const int nnodes)
pthread_mutex_t url_mlock
int XrdFfsMisc_get_all_urls_real(const char *oldurl, char **newurls, const int nnodes)
char XrdFfsMiscCururl[MAXROOTURLLEN]
void XrdFfsMisc_refresh_url_cache(const char *url)
void toChar(unsigned int r, char *d24)
time_t XrdFfsMiscUrlcachelife
#define XrdFfs_MAX_NUM_NODES
int XrdFfsPosix_stat(const char *path, struct stat *buf)
int XrdFfsQueue_count_workers()
int XrdFfsQueue_create_workers(int n)
int stat(const char *path, struct stat *buf)
const char * Name(const char *eName=0, const char **eText=0)
const char * Set(const char *hSpec, int pNum=PortInSpec)
static bool Parse(const char *hSpec, const char **hName, const char **hNend, const char **hPort, const char **hPend)
bool Stat(mode_t *flags=0, time_t *mtime=0)
XrdCl::URL * FanOut(int &num)
static void SetEnv(const char *kword, int kval)
gid_t gid
Unix gid or 0 if none.
char * grps
Entity's group name(s)
uid_t uid
Unix uid or 0 if none.
char * name
Entity's name.
bool Register(const char *lgnid, const XrdSecEntity *Ident, bool doReplace=false, bool defer=false)
thread_local XrdOucECMsg ecMsg