static int mount_point_prefix_match_0( const char * m_path,uid_t uid,string_t * m_point,int home_prefix )
{
	int st ;
	/*
	 * zuluCryptGetUserName() is defined in ../lib/user_home_path.c
	 */
	string_t uname ;
	/*
	 * below constant are set in ../constants.h
	 */
	const char * str ;

	if( home_prefix ){

		uname = zuluCryptGetUserHomePath( uid ) ;
		str = StringContent( uname ) ;
	}else{
		uname = zuluCryptGetUserName( uid ) ;
		StringPrepend( uname,"/run/media/private/" ) ;
		str = StringAppendChar( uname,'/' ) ;
	}

	st = StringPrefixEqual( m_path,str ) ;

	if( m_point ){
		*m_point = uname ;
	}else{
		StringDelete( &uname ) ;
	}

	return st ;
}
static string_t create_mount_point( const char * device,const char * label,uid_t uid )
{
	const char * m_point ;
	string_t path ;
	struct stat st ;
	mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH | S_IROTH ;

	zuluCryptSecurityGainElevatedPrivileges() ;

	path = zuluCryptGetUserName( uid ) ;

	#define path_does_not_exist( x ) stat( x,&st ) != 0
	#define path_does_exist( x ) stat( x,&st ) == 0

	if( path_does_not_exist( "/run" ) ){
		mkdir( "/run/",mode ) ;
	}else{
		_chmod( "/run",st.st_mode | S_IXOTH | S_IROTH ) ;
	}

	_chown( "/run",0,0 ) ;

	if( path_does_not_exist( "/run/media" ) ){
		mkdir( "/run/media",mode ) ;
	}else{
		_chmod( "/run/media",st.st_mode | S_IXOTH | S_IROTH ) ;
	}

	_chown( "/run/media",0,0 ) ;

	if( path_does_not_exist( "/run/media/private" ) ){
		mkdir( "/run/media/private",mode ) ;
	}else{
		_chmod( "/run/media/private",st.st_mode | S_IXOTH | S_IROTH ) ;
	}

	_chown( "/run/media/private",0,0 ) ;

	m_point = StringPrepend( path,"/run/media/private/" ) ;

	if( path_does_not_exist( m_point ) ){
		mkdir( m_point,S_IRUSR | S_IXUSR ) ;
		_chown( m_point,uid,uid ) ;
	}else{
		_chown( m_point,uid,uid ) ;
		_chmod( m_point,S_IRUSR | S_IXUSR ) ;
	}

	zuluCryptSecurityDropElevatedPrivileges() ;

	StringAppendChar( path,'/' ) ;

	if( label == NULL ){
		return _create_default_mount_point( device,uid,path ) ;
	}else{
		return _create_custom_mount_point( label,uid,path ) ;
	}
}
Beispiel #3
0
void ThetaRoleShortPrint(ThetaRole *theta_roles, int maxlen, int position,
                         Obj *cas_restrict, /* RESULTS */ char *out)
{
    out[0] = TERM;
    for (; theta_roles; theta_roles = theta_roles->next) {
        if (position != (int)theta_roles->position) continue;
        if (cas_restrict && (cas_restrict != theta_roles->cas)) continue;
        if (theta_roles->le) {
            if (out[0] != TERM) {
                StringAppendChar(out, PHRASELEN, SPACE);
            }
            if ((Bool)theta_roles->isoptional) {
                StringAppendChar(out, PHRASELEN, LPAREN);
                StringAppendDots(out, theta_roles->le->srcphrase, PHRASELEN);
                StringAppendChar(out, PHRASELEN, RPAREN);
            } else {
                StringAppendDots(out, theta_roles->le->srcphrase, PHRASELEN);
            }
        }
    }
}
Beispiel #4
0
/* Used in printing word syntax.
 * Long form; contrast with TextPrintWordAndFeatures.
 * (Both long and short forms are used by Dict.)
 */
void ThetaRoleTextPrint1(Text *text, int html, int lang, int position,
                         Obj *cas_restrict, ThetaRole *theta_roles, Obj *con,
                         Discourse *dc)
{
    int		subcat, slotnum, dospace;
    Obj		*cas, *restrict;
    Bool		isoptional;
    char		*p, buf[PHRASELEN], *s;
    LexEntry	*le;
    for (slotnum = 1; theta_roles; theta_roles = theta_roles->next, slotnum++) {
        if (theta_roles->cas == N("expl")) {
            slotnum--;
        }
        if (position != theta_roles->position) continue;
        if (cas_restrict && cas_restrict != theta_roles->cas) continue;
        ThetaRoleGet(theta_roles, &le, &cas, &subcat, &isoptional);
        if (cas == ObjNA) {
            buf[0] = LBRACE;
            buf[1] = TERM;
            p = buf+1;
        } else if (cas == N("expl")) {
            buf[0] = TERM;
            p = buf;
        } else if (isoptional) {
            buf[0] = LPAREN;
            buf[1] = TERM;
            p = buf+1;
        } else {
            buf[0] = LBRACKET;
            buf[1] = TERM;
            p = buf+1;
        }
        if (html) {
            TextPuts(buf, text);
        }
        if (cas != ObjNA && cas != N("expl")) {
            if (html) {
                HTML_TextPrint(text, GenConceptAbbrevString(cas, 1, dc));
            } else {
                StringCpy(p, GenConceptAbbrevString(cas, 1, dc), PHRASELEN-1);
            }
            dospace = 1;
        } else {
            dospace = 0;
        }
        if (con && (cas != N("expl"))) restrict = DbGetRestriction(con, slotnum);
        else restrict = NULL;
        if (restrict == N("concept") || restrict == N("object")) restrict = NULL;
        if (le) {
            if (dospace) {
                if (html) {
                    TextPutc(SPACE, text);
                } else {
                    StringAppendChar(buf, PHRASELEN, SPACE);
                }
                dospace = 0;
            }
            if (html) {
                LexEntryAddSep(le, le->srcphrase, PHRASELEN, buf);
                HTML_TextPrintBoldBeginIfEnglish(text, lang);
                HTML_TextPrint(text, buf);
                TextPutc(SPACE, text);
                HTML_TextPrintBoldEndIfEnglish(text, lang);
            } else {
                LexEntryAddSep(le, le->srcphrase, PHRASELEN, StringEndOf(buf));
            }
            if (cas != N("expl")) {
                if (html) {
                    TextPutc('+', text);
                } else {
                    StringAppendChar(buf, PHRASELEN, '+');
                }
            }
        }
        if (restrict && !ObjIsList(restrict)) {
            if (dospace) {
                if (html) {
                    TextPutc(SPACE, text);
                } else {
                    StringAppendChar(buf, PHRASELEN, SPACE);
                }
                dospace = 0;
            }
            if (html) {
                HTML_TextLinkToObj(text, restrict, 1, 0, 0);
            } else {
                GenConceptString(restrict, N("empty-article"), F_NOUN, F_NULL,
                                 DC(dc).lang, F_NULL, F_NULL, F_NULL, PHRASELEN,
                                 1, 0, dc, p = StringEndOf(buf));
                StringToUpperDestructive(p);
            }
            dospace = 1;
        }
        if (subcat != F_NULL) {
            if (html) {
                if ((s = GenFeatAbbrevString(subcat, 1, dc))) {
                    TextPuts(s, text);
                }
            } else {
                if ((s = GenFeatAbbrevString(subcat, 1, dc))) {
                    StringCat(buf, s, PHRASELEN);
                }
            }
        }
        if (html) {
            if (cas == ObjNA) TextPutc(RBRACE, text);
            else if (cas == N("expl")) Nop();
            else if (isoptional) TextPutc(RPAREN, text);
            else TextPutc(RBRACKET, text);
            TextPutc(SPACE, text);
        } else {
            if (cas == ObjNA) StringAppendChar(buf, PHRASELEN, RBRACE);
            else if (cas == N("expl")) Nop();
            else if (isoptional) StringAppendChar(buf, PHRASELEN, RPAREN);
            else StringAppendChar(buf, PHRASELEN, RBRACKET);
            TextPutword(buf, TERM, text);
        }
    }
}