/////////////////////////////////////////////////////////////////////////////// // SendInit /////////////////////////////////////////////////////////////////////////////// void cPipedMailMessage::SendInit() // throw( eMailMessageError ) { ASSERT(mpFile == 0); TSTRING strHeader; strHeader += cStringUtil::StrToTstr(cMailMessage::Create822Header()); #if !USES_MPOPEN mpFile = popen(mstrSendMailExePath.c_str(), _T("w")); #else // call mpopen, our safe version popen mpFile = mpopen((char*)mstrSendMailExePath.c_str(), _T("w")); #endif if (!mpFile) { TOSTRINGSTREAM estr; estr << TSS_GetString(cTripwire, tripwire::STR_ERR2_MAIL_MESSAGE_COMMAND) << mstrSendMailExePath; throw eMailPipedOpen(estr.str()); } SendString(strHeader); }
static int parse_cmd( const char *cmd, char *out ) { char *tmp; char buf[ 512 ]; idPlayer *player; int i; memset( buf, 0, sizeof( buf ) ); create_home(); // pwd %noparam if( LOWW(cmd) == _pw_ ) { if( *(cmd+2) != 'd' ) { return -1; } BUFF_INIT; outMsg.WriteShort( TERMINAL_STDOUT ); if( *userDir == 0 ) { sprintf( buf, "%s%d", ROOT_DIR, userId ); memcpy( userDir, buf, strlen( buf ) ); userDirLen = strlen( buf ); } memcpy( out, userDir+21, userDirLen-21 ); return 0; } // ls %noparam if( LOWW(cmd) == _ls_ ) { BUFF_INIT; outMsg.WriteShort( TERMINAL_STDOUT ); if( *userDir == 0 ) { sprintf( buf, "%s%d", ROOT_DIR, userId ); memcpy( userDir, buf, strlen( buf ) ); userDirLen = strlen( buf ); } sprintf( buf, "ls -lh %s", userDir ); mpopen( buf, out ); return 0; } // cd %param if( LOWW(cmd) == _cd_ ) { cmd += 2; if( *cmd++ != 0x20 ) { return -1; } for( tmp = cmd; *tmp != 0 && ( tmp-cmd ) <= 32; tmp++ ); if( tmp == cmd || ( tmp - cmd ) > 32 ) { return -1; } memset( userDir, 0, sizeof( userDir ) ); if( memcmp( cmd, "/", 1 ) == 0 ) { sprintf( buf, "%s%d", ROOT_DIR, userId ); memcpy( userDir, buf, strlen( buf ) ); userDirLen = strlen( buf ); return -1; } sprintf( buf, "mkdir -p %s%d/%s/", ROOT_DIR, userId, cmd ); system( buf ); memset( buf, 0, sizeof( buf ) ); sprintf( buf, "%s%d/%s/", ROOT_DIR, userId, cmd ); memcpy( userDir, buf, strlen( buf ) ); userDirLen = strlen( buf ); return -1; } // rm %param if( LOWW(cmd) == _rm_ ) { cmd += 2; if( *cmd++ != 0x20 ) { return -1; } for( tmp = cmd; *tmp != 0 && ( tmp-cmd ) <= 32; tmp++ ); if( tmp == cmd || ( tmp - cmd ) > 32 ) { return -1; } sprintf( buf, "rm -rf %s%d/%s", ROOT_DIR, userId, cmd ); system( buf ); return -1; } // vin %noparam if( LOWW(cmd) == _vi_ ) { if( *(cmd+2) != 'n' ) { return -1; } BUFF_INIT; outMsg.WriteShort( TERMINAL_FILES_LIST ); sprintf( buf, "ls -R %s%d | awk '\ /:$/&&f{s=$0;f=0}\ /:$/&&!f{sub(/:$/,\"\");s=$0;f=1;next}\