Exemplo n.º 1
0
/*
 * calendar_name@host[.domain] -> host
 */
extern char *
_DtCmsTarget2Host(char *target)
{
        char *location, *host;
 
        if ((location = _DtCmsTarget2Location(target)) != NULL) {
                host = _DtCmGetPrefix(location, '.');
                free(location);
                return(host);
        } else
                return(NULL);
}
Exemplo n.º 2
0
/*
 * owner should point to a buffer big enough to hold the owner name
 * We test whether the calendar name is a user name, if so, the
 * owner will be the same as the calendar name.
 * Otherwise, we don't know the owner.
 */
static CSA_return_code
_get_owner_from_old_cal(Calendar *cal, char *owner)
{
	char		*calname;

	if ((calname = _DtCmGetPrefix(cal->name, '@')) == NULL)
		return (CSA_E_INSUFFICIENT_MEMORY);

	if (_DtCmIsUserName(calname) == B_TRUE)
		strcpy(owner, calname);
	else
		*owner = '\0';

	free(calname);
	return (CSA_SUCCESS);
}
Exemplo n.º 3
0
/*
 * calendar_name@host[.domain] -> calendar_name
 */
extern char *
_DtCmsTarget2Name(char *target)
{
        return(_DtCmGetPrefix(target, '@'));
}
Exemplo n.º 4
0
static CSA_return_code
_DtCmsCreateCallog(char *user, cms_create_args *args, _DtCmsCalendar **newcal)
{
	CSA_return_code	stat;
	_DtCmsCalendar	*cal;
	int		i, index;
	char		datestr[80];
	char		*calname;
	char		*log;
	char		*username;
	cms_attribute_value val;
	cms_access_entry aentry;
	int		nidx = 0, oidx = 0;
	char		*name, *owner;

	/*
	 * if calendar name is a user name, make sure that
	 * it's the same as the sender.
	 */
	calname = _DtCmGetPrefix(args->cal, '@');
	username = _DtCmGetPrefix(user, '@');

	if (_DtCmIsUserName(calname) && strcmp(calname, username)) {
		free(calname);
		free(username);
		return (CSA_E_NO_AUTHORITY);
	}
	log = _DtCmsGetLogFN(calname);
	free(calname);
	free(username);

	/* create internal calendar data structure */
	if ((cal = _DtCmsMakeCalendar(user, args->cal)) == NULL) {
		free(log);
		return (CSA_E_INSUFFICIENT_MEMORY);
	}

	/* fill in information */
	_csa_tick_to_iso8601(time(0), datestr);

	if ((stat = _DtCm_set_string_attrval(datestr,
	    &cal->attrs[CSA_CAL_ATTR_DATE_CREATED_I].value,
	    CSA_VALUE_DATE_TIME)) != CSA_SUCCESS) {
		_DtCmsFreeCalendar(cal);
		free(log);
		return (stat);
	}

	/* initialize access list to be "WORLD", VIEW_PUBLIC */
	aentry.user = WORLD;
	aentry.rights = CSA_VIEW_PUBLIC_ENTRIES;
	aentry.next = NULL;
	val.item.access_list_value = &aentry;
	val.type = CSA_VALUE_ACCESS_LIST;

	if ((stat = _DtCmUpdateAccessListAttrVal(&val,
	    &cal->attrs[CSA_CAL_ATTR_ACCESS_LIST_I].value)) != CSA_SUCCESS) {
		_DtCmsFreeCalendar(cal);
		free(log);
		return (stat);
	}

	/* set product identifier */
	if ((stat = _DtCm_set_string_attrval(_DtCM_PRODUCT_IDENTIFIER,
	    &cal->attrs[CSA_CAL_ATTR_PRODUCT_IDENTIFIER_I].value,
	    CSA_VALUE_STRING)) != CSA_SUCCESS) {
		_DtCmsFreeCalendar(cal);
		free(log);
		return (stat);
	}

	/* set CSA version */
	if ((stat = _DtCm_set_string_attrval(_DtCM_SPEC_VERSION_SUPPORTED,
	    &cal->attrs[CSA_CAL_ATTR_VERSION_I].value, CSA_VALUE_STRING))
	    != CSA_SUCCESS) {
		_DtCmsFreeCalendar(cal);
		free(log);
		return (stat);
	}

	/* we dont use the values specified by client */
	for (i = 0; i < args->num_attrs; i++) {
		if (strcmp(args->attrs[i].name.name,
		    CSA_CAL_ATTR_CALENDAR_NAME) == 0) {
			nidx = i;
			name = args->attrs[i].name.name;
			args->attrs[i].name.name = NULL;
		} else if (strcmp(args->attrs[i].name.name,
		    CSA_CAL_ATTR_CALENDAR_OWNER) == 0) {
			oidx = i;
			owner = args->attrs[i].name.name;
			args->attrs[i].name.name = NULL;
		}
	}

	/* initialize calendar attribute with info provided by caller */
	if ((stat = _DtCmUpdateAttributes(args->num_attrs, args->attrs,
	    &cal->num_attrs, &cal->attrs, &cal->cal_tbl, B_TRUE,
	    NULL, B_FALSE)) != CSA_SUCCESS) {
		_DtCmsFreeCalendar(cal);
		free(log);
		return (stat);
	}

	if (nidx) args->attrs[nidx].name.name = name;
	if (oidx) args->attrs[oidx].name.name = owner;

	/* use passed in char set if client does not supply one */
	if (cal->attrs[CSA_CAL_ATTR_CHARACTER_SET_I].value == NULL &&
	     args->char_set && *args->char_set != NULL) {
		if ((stat = _DtCm_set_string_attrval(args->char_set,
		    &cal->attrs[CSA_CAL_ATTR_CHARACTER_SET_I].value,
		    CSA_VALUE_STRING)) != CSA_SUCCESS) {
			_DtCmsFreeCalendar(cal);
			free(log);
			return (stat);
		}
	}

	/* create file */
	if ((stat = _DtCmsCreateLogV2(user, log)) != CSA_SUCCESS) {
		_DtCmsFreeCalendar(cal);
		free(log);
		return (stat);
	}

	/* dump file */
	if ((stat = _DtCmsAppendCalAttrsByFN(log, cal->num_attrs, cal->attrs))
	    != CSA_SUCCESS) {
		free(log);
		unlink(log);
		_DtCmsFreeCalendar(cal);
		return (stat);
	}
	free(log);

	_DtCmsPutInCalList(cal);

	*newcal = cal;

	return (stat);
}