@@ -107,8 +107,7 @@ int main ( int argc, char* argv [] )
107
107
printf ( " -n Disable the usage of ncurses (For screenlog)\n " );
108
108
#ifndef WIN32
109
109
printf ( " -x Disable simplified crash reports (To allow core dumps)\n " );
110
- printf ( " -p Always add linux-libs directory to library search path\n " );
111
- printf ( " -q Never add linux-libs directory to library search path\n " );
110
+ printf ( " -q Do not add " LINUX_LIBS_PATH " directory to library search path\n " );
112
111
#endif
113
112
printf ( " -D [PATH] Use as base directory\n " );
114
113
printf ( " --config [FILE] Alternate mtaserver.conf file\n " );
@@ -186,70 +185,50 @@ int main ( int argc, char* argv [] )
186
185
187
186
#ifndef WIN32
188
187
//
189
- // Add linux-libs to library search path if either :
188
+ // Add linux-libs to library search path if:
190
189
// 1. Options don't forbid it (-q)
191
- // 2. Options force it (-p)
192
- // 3. net.so is not loadable
190
+ // 2. linux-libs is not already in the library search path
193
191
//
194
192
void HandleLinuxLibs ( const SString& strLaunchDirectory, int argc, char * argv [] )
195
193
{
196
- // Check linux-libs options
197
- bool bUseLinuxLibs = false ;
198
- bool bForbidLinuxLibs = false ;
194
+ // Check for linux-libs forbidden option
199
195
for ( int i = 1 ; i < argc ; i++ )
200
196
{
201
- bUseLinuxLibs |= ( strcmp ( argv[i], " -p " ) == 0 );
202
- bForbidLinuxLibs |= ( strcmp ( argv[i], " -q " ) == 0 ) ;
197
+ if ( strcmp ( argv[i], " -q " ) == 0 )
198
+ return ;
203
199
}
204
200
205
- // Is linux-libs forbidden by options?
206
- if ( bForbidLinuxLibs )
207
- return ;
208
-
209
201
// Calculate absolute path to MTA directory
210
202
SString strSavedDir = GetSystemCurrentDirectory ();
211
203
chdir ( strLaunchDirectory );
212
204
SString strAbsLaunchDirectory = GetSystemCurrentDirectory ();
213
205
chdir ( strSavedDir );
214
206
215
- if ( !bUseLinuxLibs )
216
- {
217
- // linux-libs not forced by options - Check if net module might need it
218
- void * hModule = dlopen ( strAbsLaunchDirectory + " /" LIB_NET, RTLD_NOW );
219
- if ( hModule )
220
- dlclose ( hModule );
221
- else
222
- bUseLinuxLibs = true ;
223
- }
207
+ SString strLdLibraryPath = getenv ( " LD_LIBRARY_PATH" );
208
+ SString strLinuxLibsPath = strAbsLaunchDirectory + " /" LINUX_LIBS_PATH;
224
209
225
- if ( bUseLinuxLibs )
210
+ // Check that linux-libs is not already in library path
211
+ if ( !strLdLibraryPath.Contains ( strLinuxLibsPath ) )
226
212
{
227
- SString strLdLibraryPath = getenv ( " LD_LIBRARY_PATH" );
228
- SString strLinuxLibsPath = strAbsLaunchDirectory + " /" LINUX_LIBS_PATH;
229
-
230
- // Check that linux-libs is not already in library path
231
- if ( !strLdLibraryPath.Contains ( strLinuxLibsPath ) )
213
+ // Add linux-libs to search path
214
+ if ( !strLdLibraryPath.empty () )
215
+ strLdLibraryPath += " ;" ;
216
+ strLdLibraryPath += strLinuxLibsPath;
217
+ SString strEnvString = SStringX ( " LD_LIBRARY_PATH=" ) + strLdLibraryPath;
218
+ putenv ( (char *)*strEnvString );
219
+
220
+ // Add -q to ensure linux-libs don't get added again
221
+ char ** pArgArray = new char *[argc + 2 ];
222
+ for ( int i = 0 ; i <= argc ; i++ )
232
223
{
233
- // Add linux-libs to search path
234
- if ( !strLdLibraryPath.empty () )
235
- strLdLibraryPath += " ;" ;
236
- strLdLibraryPath += strLinuxLibsPath;
237
- SString strEnvString = SStringX ( " LD_LIBRARY_PATH=" ) + strLdLibraryPath;
238
- putenv ( (char *)*strEnvString );
239
-
240
- // Add -q to ensure linux-libs don't get added again
241
- char ** pArgArray = new char *[argc + 2 ];
242
- for ( int i = 0 ; i <= argc ; i++ )
243
- {
244
- pArgArray[i] = argv[i];
245
- }
246
- char newArg[] = " -q" ;
247
- pArgArray[argc] = newArg;
248
- pArgArray[argc + 1 ] = nullptr ;
249
-
250
- // Go for launch #2
251
- execv ( argv[0 ], pArgArray );
224
+ pArgArray[i] = argv[i];
252
225
}
226
+ char newArg[] = " -q" ;
227
+ pArgArray[argc] = newArg;
228
+ pArgArray[argc + 1 ] = nullptr ;
229
+
230
+ // Go for launch #2
231
+ execv ( argv[0 ], pArgArray );
253
232
}
254
233
}
255
234
#endif
0 commit comments