Эх сурвалжийг харах

automatische speicherabbild erstellung bei server crashes

Kolja Strohm 6 жил өмнө
parent
commit
aa1697497a

+ 2 - 1
AppServer Linux/AppServer Linux.vcxproj

@@ -70,7 +70,7 @@
       <LibraryDependencies>dbgFramework;dbgNetwork;dbgSQL;pq;pthread</LibraryDependencies>
       <SharedLibrarySearchPath>%(SharedLibrarySearchPath)</SharedLibrarySearchPath>
       <AdditionalLibraryDirectories>$(RemoteRootDir)/Framework/debug/bin/x64/debug;$(RemoteRootDir)/Network/debug/bin/x64/debug;$(RemoteRootDir)/sql/debug/bin/x64/debug;/usr/lib/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
-      <AdditionalOptions>-Wl,-rpath,/test/lib %(AdditionalOptions)</AdditionalOptions>
+      <AdditionalOptions>-Wl,-rpath,../lib %(AdditionalOptions)</AdditionalOptions>
     </Link>
     <ClCompile />
   </ItemDefinitionGroup>
@@ -78,6 +78,7 @@
     <Link>
       <LibraryDependencies>Framework;Network;SQL;pq;pthread</LibraryDependencies>
       <AdditionalLibraryDirectories>$(RemoteRootDir)/Framework/release/bin/x64/release;$(RemoteRootDir)/Network/release/bin/x64/release;$(RemoteRootDir)/sql/release/bin/x64/release;/usr/lib/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalOptions>-Wl,-rpath,../lib %(AdditionalOptions)</AdditionalOptions>
     </Link>
     <ClCompile>
       <AdditionalOptions>-Wl,-rpath,../lib %(AdditionalOptions)</AdditionalOptions>

+ 0 - 61
AppServer/AppServer.cpp

@@ -826,67 +826,6 @@ void AppSKlient::thread()
                     delete[]acc_mail;
                 }
                 break;
-            case 21: // Account bestätigen
-                if( 1 )
-                {
-                    klient->sendeEncrypted( "\1", 1 );
-                    unsigned char len[ 2 ];
-                    klient->getNachrichtEncrypted( (char*)len, 2 );
-                    char *accName = new char[ len[ 0 ] + 1 ];
-                    accName[ len[ 0 ] ] = 0;
-                    klient->getNachrichtEncrypted( accName, len[ 0 ] );
-                    char *accPasswort = new char[ len[ 1 ] + 1 ];
-                    accPasswort[ len[ 1 ] ] = 0;
-                    klient->getNachrichtEncrypted( accPasswort, len[ 1 ] );
-                    char byte = appS->zDB()->suchBestaetigung( accName, accPasswort );
-                    if( !byte )
-                        klient->sendeEncrypted( "\0", 1 );
-                    else if( byte == -1 )
-                        klient->sendeEncrypted( "\0", 1 );
-                    else if( byte > 0 )
-                    {
-                        klient->sendeEncrypted( &byte, 1 );
-                        char befehl = 0;
-                        while( 1 )
-                        {
-                            klient->getNachrichtEncrypted( &befehl, 1 );
-                            if( !befehl )
-                            {
-                                if( byte == 1 )
-                                    appS->zDB()->neuAccountAbbruch( accName );
-                                break;
-                            }
-                            if( befehl == -1 )
-                                break;
-                            if( befehl == -2 )
-                            {
-                                if( byte == 1 )
-                                    appS->zDB()->sendeErstellEMail( accName, appS->zIni() );
-                            }
-                            if( befehl > 0 )
-                            {
-                                char *key = new char[ befehl + 1 ];
-                                key[ (int)befehl ] = 0;
-                                klient->getNachrichtEncrypted( key, befehl );
-                                if( byte == 1 )
-                                {
-                                    if( !appS->zDB()->aktiviereAccount( accName, key ) )
-                                        klient->sendeEncrypted( "\0", 1 );
-                                    else
-                                    {
-                                        klient->sendeEncrypted( "\1", 1 );
-                                        delete[]key;
-                                        break;
-                                    }
-                                }
-                                delete[]key;
-                            }
-                        }
-                    }
-                    delete[]accName;
-                    delete[]accPasswort;
-                }
-                break;
             case 22: // Trennen
                 klient->sendeEncrypted( "\1", 1 );
                 br = 1;

+ 5 - 150
AppServer/Datenbank.cpp

@@ -615,50 +615,19 @@ bool AppSDatenbank::neuAccount( const char *name, const char *pass, const char *
     if( datenbank->befehl( befehl->getText() ) )
     {
         unlock();
-        befehl->setText( "SELECT schluessel FROM account_neu WHERE name = '" );
+        befehl->setText( "SELECT schluessel, id FROM account_neu WHERE name = '" );
         befehl->append( (char*)n );
         befehl->append( "'" );
         lock();
         datenbank->befehl( befehl->getText() );
         Result res = datenbank->getResult();
         unlock();
-        Datei md;
         if( res.zeilenAnzahl )
         {
-            md.setDatei( res.values[ 0 ].getText() );
-            if( md.open( Datei::Style::schreiben ) )
-            {
-                Text txt = eMail;
-                txt += "\naccount activation\n Account Details:\n";
-                txt += "\r\nname: ";
-                txt += name;
-                txt += "\r\npassword: ";
-                txt += pass;
-                txt += "\r\nsecret: ";
-                txt += geheim;
-                txt += "\r\ndate of birth: ";
-                txt += gebDatum;
-                txt += "\r\nactivation key: ";
-                txt += res.values[ 0 ].getText();
-                md.schreibe( txt, txt.getLength() );
-                md.close();
-                // e_mail senden
-#ifdef WIN32
-                PROCESS_INFORMATION prozessinfo1;
-                STARTUPINFO startinfo1;
-                startinfo1.cb = sizeof( STARTUPINFOW );
-                ZeroMemory( &startinfo1, sizeof( STARTUPINFOW ) );
-                Text cmdl = zIni->zWert( "Java" )->getText();
-                cmdl += " Mailer ";
-                cmdl += res.values[ 0 ].getText();
-                if( CreateProcess( 0, cmdl, 0, 0, 0, 0, 0, 0, &startinfo1, &prozessinfo1 ) == 1 )
-                    CloseHandle( prozessinfo1.hThread );
-#else
-                pid_t pid;
-                char *pargs[] = { zIni->zWert( "Java" )->getText(), ( char* )"Mailer", res.values[ 0 ].getText(), (char*)0 };
-                posix_spawn( &pid, zIni->zWert( "Java" )->getText(), 0, 0, pargs, 0 );
-#endif
-            }
+            // e_mail senden
+            pid_t pid;
+            char *pargs[] = { zIni->zWert( "PHP" )->getText(), zIni->zWert( "AccountActivationMail" )->getText(), (char*)name, (char*)geheim, (char*)gebDatum, res.values[ 0 ].getText(), (char*)eMail, res.values[ 1 ].getText(), (char*)0 };
+            posix_spawn( &pid, zIni->zWert( "PHP" )->getText(), 0, 0, pargs, 0 );
         }
         res.destroy();
         befehl->release();
@@ -669,120 +638,6 @@ bool AppSDatenbank::neuAccount( const char *name, const char *pass, const char *
     return 0;
 }
 
-void AppSDatenbank::neuAccountAbbruch( const char *name )
-{
-    Text *befehl = new Text( "DELETE FROM account_neu WHERE name = '" );
-    Text n( name );
-    n.ersetzen( "'", "''" );
-    befehl->append( (char*)n );
-    befehl->append( "'" );
-    lock();
-    datenbank->befehl( befehl->getText() );
-    unlock();
-    befehl->release();
-}
-
-bool AppSDatenbank::aktiviereAccount( const char *name, const char *key )
-{
-    Text *befehl = new Text( "SELECT account_aktivieren( '" );
-    Text n( name );
-    n.ersetzen( "'", "''" );
-    befehl->append( (char*)n );
-    befehl->append( "', '" );
-    Text s( key );
-    s.ersetzen( "'", "''" );
-    befehl->append( (char*)s );
-    befehl->append( "' )" );
-    lock();
-    if( datenbank->befehl( befehl->getText() ) )
-    {
-        befehl->release();
-        Result res = datenbank->getResult();
-        unlock();
-        if( res.values[ 0 ].istGleich( "f" ) )
-        {
-            res.destroy();
-            return 0;
-        }
-        return 1;
-    }
-    unlock();
-    befehl->release();
-    return 0;
-}
-
-char AppSDatenbank::suchBestaetigung( const char *name, const char *pass )
-{
-    Text *befehl = new Text( "select such_account_bestaetigung( '" );
-    Text n( name );
-    n.ersetzen( "'", "''" );
-    befehl->append( (char*)n );
-    befehl->append( "', md5('" );
-    Text p( pass );
-    p.ersetzen( "'", "''" );
-    befehl->append( (char*)p );
-    befehl->append( "') )" );
-    lock();
-    datenbank->befehl( befehl->getText() );
-    Result res = datenbank->getResult();
-    unlock();
-    befehl->release();
-    char ret = (char)TextZuInt( res.values[ 0 ].getText(), 10 );
-    res.destroy();
-    return ret;
-}
-
-void AppSDatenbank::sendeErstellEMail( const char *name, InitDatei *zIni )
-{
-    Text *befehl = new Text( "SELECT geheimnis, e_mail, geb_datum, schluessel FROM account_neu WHERE name = '" );
-    Text n( name );
-    n.ersetzen( "'", "''" );
-    befehl->append( (char*)n );
-    befehl->append( "'" );
-    lock();
-    datenbank->befehl( befehl->getText() );
-    Result res = datenbank->getResult();
-    unlock();
-    befehl->release();
-    Datei md;
-    if( res.zeilenAnzahl )
-    {
-        md.setDatei( res.values[ 3 ].getText() );
-        if( md.open( Datei::Style::schreiben ) )
-        {
-            Text txt = res.values[ 1 ].getText();
-            txt += "\naccount activation\n Account Details:\n";
-            txt += "\r\nname: ";
-            txt += name;
-            txt += "\r\nsecret: ";
-            txt += res.values[ 0 ].getText();
-            txt += "\r\ndate of birth: ";
-            txt += res.values[ 2 ].getText();
-            txt += "\r\nactivation key: ";
-            txt += res.values[ 3 ].getText();
-            md.schreibe( txt, txt.getLength() );
-            md.close();
-            // e_mail senden
-#ifdef WIN32
-            PROCESS_INFORMATION prozessinfo1;
-            STARTUPINFO startinfo1;
-            startinfo1.cb = sizeof( STARTUPINFOW );
-            ZeroMemory( &startinfo1, sizeof( STARTUPINFOW ) );
-            Text cmdl = zIni->zWert( "Java" )->getText();
-            cmdl += " Mailer ";
-            cmdl += res.values[ 4 ].getText();
-            if( CreateProcess( 0, cmdl, 0, 0, 0, 0, 0, 0, &startinfo1, &prozessinfo1 ) == 1 )
-                CloseHandle( prozessinfo1.hThread );
-#else
-            pid_t pid;
-            char *pargs[] = { zIni->zWert( "Java" )->getText(), ( char* )"Mailer", res.values[ 4 ].getText(), (char*)0 };
-            posix_spawn( &pid, zIni->zWert( "Java" )->getText(), 0, 0, pargs, 0 );
-#endif
-        }
-    }
-    res.destroy();
-}
-
 void AppSDatenbank::markballsFinish( int level, int sek, int account, char *device, int diff, int kupfer, int gId )
 {
     if( !device && kupfer > 0 )

+ 0 - 4
AppServer/Datenbank.h

@@ -56,10 +56,6 @@ public:
     void calkGesamtScore( int account );
     int pruefNeuAccount( const char *name, const char *eMail );
     bool neuAccount( const char *name, const char *pass, const char *geheim, const char *eMail, const char *gebDatum, InitDatei *zIni );
-    void neuAccountAbbruch( const char *name );
-    bool aktiviereAccount( const char *name, const char *key );
-    char suchBestaetigung( const char *name, const char *pass );
-    void sendeErstellEMail( const char *name, InitDatei *zIni );
     void markballsFinish( int level, int sek, int account, char *device, int diff, int kupfer, int gId );
     int getMarkballsScore( Array< int > *level, Array< int > *score, RCArray< Text > *name, int diff );
     int getMarkballsScore( Array< int > *level, Array< int > *score, int diff );

+ 8 - 2
AppServer/main.cpp

@@ -5,11 +5,17 @@
 #include <Datei.h>
 #include <Text.h>
 #include <Globals.h>
+#include <sys/resource.h>
 
 int main()
 {
+	struct rlimit core_limits;
+	core_limits.rlim_cur = core_limits.rlim_max = RLIM_INFINITY;
+	setrlimit(RLIMIT_CORE, &core_limits);
+
 	Framework::initFramework();
-	chdir( "/test/app" );
+    //if( chdir( "/test/app" ) == -1 )
+    //    return -1;
 	Zeit *z = getZeit();
 	Text *pfad = new Text( "../log/app/" );
 	pfad->append( z->getZeit( "y-m-d h-i-s.log" ) );
@@ -31,7 +37,7 @@ int main()
 		dat->release();
 		exit( 1 );
 	}
-	const char *wichtig[] = { "ServerId", "DBBenutzer", "DBPasswort", "DBName", "DBIP", "DBPort", "DataPfad", "Java", "Mailer", "Aktive" };
+	const char *wichtig[] = { "ServerId", "DBBenutzer", "DBPasswort", "DBName", "DBIP", "DBPort", "PHP", "AccountActivationMail", "Aktiv" };
 	for( const char *w : wichtig )
 	{
 		if( !dat->wertExistiert( w ) )