wrapper 

Commit MetaInfo

Revision166 (tree)
Time2012-02-08 16:33:46
Authormortenson

Log Message

Prepare for 3.5.14 release.

Change Summary

Diff

--- trunk/wrapper/README_es.txt (revision 165)
+++ trunk/wrapper/README_es.txt (revision 166)
@@ -1,5 +1,5 @@
11 -----------------------------------------------------------------------------
2-Java Service Wrapper Community Edition 3.5.14-a
2+Java Service Wrapper Community Edition 3.5.14
33 Copyright (C) 1999-2011 Tanuki Software, Ltd. All Rights Reserved.
44 http://wrapper.tanukisoftware.com
55 -----------------------------------------------------------------------------
--- trunk/wrapper/README_de.txt (revision 165)
+++ trunk/wrapper/README_de.txt (revision 166)
@@ -1,5 +1,5 @@
11 -----------------------------------------------------------------------------
2-Java Service Wrapper Community Edition 3.5.14-a
2+Java Service Wrapper Community Edition 3.5.14
33 Copyright (C) 1999-2011 Tanuki Software, Ltd. All Rights Reserved.
44 http://wrapper.tanukisoftware.com
55 -----------------------------------------------------------------------------
--- trunk/wrapper/README_ja.txt (revision 165)
+++ trunk/wrapper/README_ja.txt (revision 166)
@@ -1,5 +1,5 @@
11 -----------------------------------------------------------------------------
2-Java Service Wrapper Community Edition 3.5.14-a
2+Java Service Wrapper Community Edition 3.5.14
33 Copyright (C) 1999-2011 Tanuki Software, Ltd. All Rights Reserved.
44 http://wrapper.tanukisoftware.com
55 -----------------------------------------------------------------------------
--- trunk/wrapper/doc/revisions.txt (revision 165)
+++ trunk/wrapper/doc/revisions.txt (revision 166)
@@ -2,6 +2,13 @@
22 --------------------------------------
33
44 3.5.14
5+* Fix a problem in the AppCommand.bat.in file where a parenthesis in the
6+ file name of the Wrapper binary would have caused a
7+ "PATH was unexpected at this time" error.
8+* (Standard, Professional) Fix a problem when using a localized version of
9+ the Wrapper on Windows 64-bit platforms where the Wrapper would continue
10+ to use the default system language even wrapper.lang was used to specify
11+ a different language. Introduced in 3.5.12.
512 * Fix a problem in the Windows AppCommand.bat.in command based batch file
613 where the 'status' command was incorrectly being reported as 'query' in the
714 usage output. The 'status' command had always worked correctly if used.
@@ -17,6 +24,29 @@
1724 read-only check of the pid file.
1825 * Fix a problem with the UNIX script where the 'remove' command was trying to
1926 stop a running application even when the application had not been installed.
27+* Fix a buffer overflow which could potentially cause a crash during the
28+ installation of a Windows Service when wrapper.ntservice.account was
29+ specified. This was introduced in 3.5.12.
30+* Fix a heap corruption which could occur on startup and potentially cause a
31+ crash. Only Windows systems, which use the System Event logs, were affected.
32+ Discovered from a code review, there had never been any reports of this
33+ causing problems for users. This could happen if the configured wrapper.log
34+ could not be written to as the Wrapper always tries to write to the Event
35+ Log in such cases. Introduced in 3.5.12.
36+* Add a new version comparison between the UNIX shell script and Wrapper to
37+ start showing a warning in case of a version mismatch. The check will only
38+ work if the shell script and Wrapper are each of at least version 3.5.14.
39+* Added a new wrapper.pidfile.strict property which will tell the Wrapper not
40+ to start if the pid file already existed. Defaults to false for backwards
41+ compatibility.
42+* Make the Java side of the backend socket more resilient in case of a read
43+ or write timeout. The backend socket does not have a timeout set by default
44+ so this should not have been an issue. A couple users reported problems on
45+ specific systems however which led to this fix.
46+* To aid in the testing of the backend socket timeout, a new
47+ wrapper.backend.so_timeout system property was added to make it possible to
48+ configure the backend socket to use a timeout. See the Javadocs of the
49+ WrapperManager class for details.
2050
2151 3.5.13
2252 * Fix a typo in the script where the environment variable 'TR_BIN' should
--- trunk/wrapper/src/java/org/tanukisoftware/wrapper/WrapperManager.java (revision 165)
+++ trunk/wrapper/src/java/org/tanukisoftware/wrapper/WrapperManager.java (revision 166)
@@ -48,6 +48,7 @@
4848 import java.net.ServerSocket;
4949 import java.net.Socket;
5050 import java.net.SocketException;
51+import java.net.SocketTimeoutException;
5152 import java.net.UnknownHostException;
5253 import java.net.URL;
5354 import java.security.CodeSource;
@@ -105,6 +106,13 @@
105106 * localhost and will expect to receive the key specified in a property
106107 * named "wrapper.key".
107108 *
109+ * When the backend connection is a socket, it does not have any timeout
110+ * set by default. For testing purposes it is possible to set a timeout
111+ * in seconds using the following system property when launching the JVM.
112+ * This will only be noticeable if it is shorter than the ping interval,
113+ * and debug output is enabled:
114+ * -Dwrapper.backend.ro_timeout=300
115+ *
108116 * This class is implemented as a singleton class.
109117 *
110118 * Generate JNI Headers with the following command in the build/classes
@@ -119,7 +127,6 @@
119127 private static final String WRAPPER_CONNECTION_THREAD_NAME = "Wrapper-Connection";
120128
121129 private static final int DEFAULT_PORT = 15003;
122- private static final int DEFAULT_SO_TIMEOUT = 10000;
123130 private static final int DEFAULT_CPU_TIMEOUT = 10000;
124131
125132 /** The number of milliseconds in one tick. Used for internal system
@@ -317,6 +324,7 @@
317324 private static int m_jvmPortMin;
318325 private static int m_jvmPortMax;
319326 private static String m_key;
327+ private static int m_soTimeout = 0;
320328 private static long m_cpuTimeout = DEFAULT_CPU_TIMEOUT;
321329
322330 /** Tick count when the start method completed. */
@@ -630,6 +638,9 @@
630638 m_listenerForceStop = WrapperSystemPropertyUtil.getBooleanProperty(
631639 "wrapper.listener.force_stop", false );
632640
641+ // Make it possible for a user to set the SO_TIMEOUT of the backend. Mainly for testing.
642+ m_soTimeout = WrapperSystemPropertyUtil.getIntProperty( "wrapper.backend.so_timeout", 0 ) * 1000;
643+
633644 // If the shutdown hook is not disabled, then register it.
634645 if ( !disableShutdownHook )
635646 {
@@ -2182,7 +2193,7 @@
21822193 }
21832194
21842195 /**
2185- * Returns true if the current JVM is Windows.
2196+ * Returns true if the current JVM is Mac OSX.
21862197 *
21872198 * @return True if this is Mac OSX.
21882199 *
@@ -4741,6 +4752,18 @@
47414752 // Turn on the TCP_NODELAY flag. This is very important for speed!!
47424753 m_backendSocket.setTcpNoDelay( true );
47434754
4755+ // If configured, set the SO_TIMEOUT for the socket (max block time)
4756+ if ( m_soTimeout > 0 )
4757+ {
4758+ if ( m_debug )
4759+ {
4760+ m_outDebug.println( getRes().getString( "Setting backend socket SO_TIMEOUT to {0}ms from {1}ms.",
4761+ new Integer( m_soTimeout ), new Integer( m_backendSocket.getSoTimeout() ) ) );
4762+ }
4763+
4764+ m_backendSocket.setSoTimeout( m_soTimeout );
4765+ }
4766+
47444767 m_backendOS = m_backendSocket.getOutputStream();
47454768 m_backendIS = m_backendSocket.getInputStream();
47464769 }
@@ -5099,219 +5122,230 @@
50995122 DataInputStream is = new DataInputStream( m_backendIS );
51005123 while ( !m_disposed )
51015124 {
5102- // A Packet code must exist.
5103- byte code = is.readByte();
5104-
5105- // Always read from the buffer until a null '\0' is encountered.
5106- byte b;
5107- int i = 0;
5108- do
5125+ try
51095126 {
5110- b = is.readByte();
5111- if ( b != 0 )
5127+ // A Packet code must exist.
5128+ byte code = is.readByte();
5129+
5130+ // Always read from the buffer until a null '\0' is encountered.
5131+ byte b;
5132+ int i = 0;
5133+ do
51125134 {
5113- if ( i >= m_backendReadBuffer.length )
5135+ b = is.readByte();
5136+ if ( b != 0 )
51145137 {
5115- byte[] tmp = m_backendReadBuffer;
5116- m_backendReadBuffer = new byte[tmp.length + 256];
5117- System.arraycopy( tmp, 0, m_backendReadBuffer, 0, tmp.length );
5138+ if ( i >= m_backendReadBuffer.length )
5139+ {
5140+ byte[] tmp = m_backendReadBuffer;
5141+ m_backendReadBuffer = new byte[tmp.length + 256];
5142+ System.arraycopy( tmp, 0, m_backendReadBuffer, 0, tmp.length );
5143+ }
5144+ m_backendReadBuffer[i] = b;
5145+ i++;
51185146 }
5119- m_backendReadBuffer[i] = b;
5120- i++;
51215147 }
5122- }
5123- while ( b != 0 );
5124-
5125- String msg = new String( m_backendReadBuffer, 0, i );
5126-
5127- if ( m_appearHung )
5128- {
5129- // The WrapperManager is attempting to make the JVM appear hung,
5130- // so ignore all incoming requests
5131- }
5132- else
5133- {
5134- if ( m_debug )
5148+ while ( b != 0 );
5149+
5150+ String msg = new String( m_backendReadBuffer, 0, i );
5151+
5152+ if ( m_appearHung )
51355153 {
5136- String logMsg;
5137- if ( code == WRAPPER_MSG_PROPERTIES )
5138- {
5139- // The property values are very large and distracting in the log.
5140- // Plus if any triggers are defined, then logging them will fire
5141- // the trigger.
5142- logMsg = getRes().getString( "(Property Values)" );
5143- }
5144- else
5145- {
5146- logMsg = msg;
5147- }
5148-
5149- // Don't log silent pings.
5150- if ( ( code == WRAPPER_MSG_PING ) && ( msg.equals( "silent" ) ) )
5151- {
5152- //m_outDebug.println( "Received silent ping packet." );
5153- }
5154- else
5155- {
5156- m_outDebug.println( getRes().getString( "Received a packet {0} : {1}",
5157- getPacketCodeName( code ) , logMsg ) );
5158- }
5154+ // The WrapperManager is attempting to make the JVM appear hung,
5155+ // so ignore all incoming requests
51595156 }
5160-
5161- // Ok, we got a packet. Do something with it.
5162- switch( code )
5157+ else
51635158 {
5164- case WRAPPER_MSG_START:
5165- // Don't start if we are already starting to stop.
5166- if ( m_stoppingInit) {
5167- if ( m_debug )
5159+ if ( m_debug )
5160+ {
5161+ String logMsg;
5162+ if ( code == WRAPPER_MSG_PROPERTIES )
51685163 {
5169- m_outDebug.println( getRes().getString( "Java stop initiated. Skipping application startup." ) );
5164+ // The property values are very large and distracting in the log.
5165+ // Plus if any triggers are defined, then logging them will fire
5166+ // the trigger.
5167+ logMsg = getRes().getString( "(Property Values)" );
51705168 }
5171- } else {
5172- startInner( false );
5173- }
5174- break;
5175-
5176- case WRAPPER_MSG_STOP:
5177- // Don't do anything if we are already stopping
5178- if ( !m_stopping )
5179- {
5180- privilegedStopInner( 0 );
5181- // Should never get back here.
5182- }
5183- break;
5184-
5185- case WRAPPER_MSG_PING:
5186- m_lastPingTicks = getTicks();
5187-
5188- sendCommand( WRAPPER_MSG_PING, msg );
5189-
5190- if ( m_produceCoreEvents )
5191- {
5192- fireWrapperEvent( pingEvent );
5193- }
5194-
5195- break;
5196-
5197- case WRAPPER_MSG_CHECK_DEADLOCK:
5198- boolean deadLocked = checkDeadlocks();
5199- if ( deadLocked )
5200- {
5201- sendCommand( WRAPPER_MSG_DEADLOCK, "deadLock" );
5202- }
5203- break;
5204-
5205- case WRAPPER_MSG_BADKEY:
5206- // The key sent to the wrapper was incorrect. We need to shutdown.
5207- m_outError.println( getRes().getString("Authorization key rejected by Wrapper." ) );
5208- m_outError.println( getRes().getString( "Exiting JVM..." ) );
5209- closeBackend();
5210- privilegedStopInner( 1 );
5211- break;
5212-
5213- case WRAPPER_MSG_LOW_LOG_LEVEL:
5214- try
5215- {
5216- m_lowLogLevel = Integer.parseInt( msg );
5217- m_debug = ( m_lowLogLevel <= WRAPPER_LOG_LEVEL_DEBUG );
5218- if ( m_debug )
5169+ else
52195170 {
5220- m_outDebug.println( getRes().getString( "LowLogLevel from Wrapper is {0}",
5221- new Integer( m_lowLogLevel ) ) );
5171+ logMsg = msg;
52225172 }
5223- }
5224- catch ( NumberFormatException e )
5225- {
5226- m_outError.println( getRes().getString(
5227- "Encountered an Illegal LowLogLevel from the Wrapper: {0}", msg ) );
5228- }
5229- break;
5230-
5231- case WRAPPER_MSG_PING_TIMEOUT:
5232- /* No longer used. This is still here in case a mix of versions are used. */
5233- break;
5234-
5235- case WRAPPER_MSG_SERVICE_CONTROL_CODE:
5236- try
5237- {
5238- int serviceControlCode = Integer.parseInt( msg );
5239- if ( m_debug )
5173+
5174+ // Don't log silent pings.
5175+ if ( ( code == WRAPPER_MSG_PING ) && ( msg.equals( "silent" ) ) )
52405176 {
5241- m_outDebug.println( getRes().getString(
5242- "ServiceControlCode from Wrapper with code {0}",
5243- new Integer( serviceControlCode ) ) );
5177+ //m_outDebug.println( "Received silent ping packet." );
52445178 }
5245- WrapperServiceControlEvent event =
5246- new WrapperServiceControlEvent( serviceControlCode );
5247- fireWrapperEvent( event );
5248- }
5249- catch ( NumberFormatException e )
5250- {
5251- m_outError.println( getRes().getString(
5252- "Encountered an Illegal ServiceControlCode from the Wrapper: {0}", msg ) );
5253- }
5254- break;
5255-
5256- case WRAPPER_MSG_PAUSE:
5257- try
5258- {
5259- int actionCode = Integer.parseInt( msg );
5260- if ( m_debug )
5179+ else
52615180 {
5262- m_outDebug.println( getRes().getString( "Pause from Wrapper with code {0}", new Integer( actionCode ) ) );
5181+ m_outDebug.println( getRes().getString( "Received a packet {0} : {1}",
5182+ getPacketCodeName( code ) , logMsg ) );
52635183 }
5264- WrapperServicePauseEvent event =
5265- new WrapperServicePauseEvent( actionCode );
5266- fireWrapperEvent( event );
52675184 }
5268- catch ( NumberFormatException e )
5269- {
5270- m_outError.println( getRes().getString(
5271- "Encountered an Illegal ActionCode from the Wrapper: {0}", msg ) );
5272- }
5273- break;
52745185
5275- case WRAPPER_MSG_RESUME:
5276- try
5186+ // Ok, we got a packet. Do something with it.
5187+ switch( code )
52775188 {
5278- int actionCode = Integer.parseInt( msg );
5279- if ( m_debug )
5189+ case WRAPPER_MSG_START:
5190+ // Don't start if we are already starting to stop.
5191+ if ( m_stoppingInit) {
5192+ if ( m_debug )
5193+ {
5194+ m_outDebug.println( getRes().getString( "Java stop initiated. Skipping application startup." ) );
5195+ }
5196+ } else {
5197+ startInner( false );
5198+ }
5199+ break;
5200+
5201+ case WRAPPER_MSG_STOP:
5202+ // Don't do anything if we are already stopping
5203+ if ( !m_stopping )
52805204 {
5281- m_outDebug.println( getRes().getString("Resume from Wrapper with code {0}", new Integer( actionCode ) ) );
5205+ privilegedStopInner( 0 );
5206+ // Should never get back here.
52825207 }
5283- WrapperServiceResumeEvent event =
5284- new WrapperServiceResumeEvent( actionCode );
5208+ break;
5209+
5210+ case WRAPPER_MSG_PING:
5211+ m_lastPingTicks = getTicks();
5212+
5213+ sendCommand( WRAPPER_MSG_PING, msg );
5214+
5215+ if ( m_produceCoreEvents )
5216+ {
5217+ fireWrapperEvent( pingEvent );
5218+ }
5219+
5220+ break;
5221+
5222+ case WRAPPER_MSG_CHECK_DEADLOCK:
5223+ boolean deadLocked = checkDeadlocks();
5224+ if ( deadLocked )
5225+ {
5226+ sendCommand( WRAPPER_MSG_DEADLOCK, "deadLock" );
5227+ }
5228+ break;
5229+
5230+ case WRAPPER_MSG_BADKEY:
5231+ // The key sent to the wrapper was incorrect. We need to shutdown.
5232+ m_outError.println( getRes().getString("Authorization key rejected by Wrapper." ) );
5233+ m_outError.println( getRes().getString( "Exiting JVM..." ) );
5234+ closeBackend();
5235+ privilegedStopInner( 1 );
5236+ break;
5237+
5238+ case WRAPPER_MSG_LOW_LOG_LEVEL:
5239+ try
5240+ {
5241+ m_lowLogLevel = Integer.parseInt( msg );
5242+ m_debug = ( m_lowLogLevel <= WRAPPER_LOG_LEVEL_DEBUG );
5243+ if ( m_debug )
5244+ {
5245+ m_outDebug.println( getRes().getString( "LowLogLevel from Wrapper is {0}",
5246+ new Integer( m_lowLogLevel ) ) );
5247+ }
5248+ }
5249+ catch ( NumberFormatException e )
5250+ {
5251+ m_outError.println( getRes().getString(
5252+ "Encountered an Illegal LowLogLevel from the Wrapper: {0}", msg ) );
5253+ }
5254+ break;
5255+
5256+ case WRAPPER_MSG_PING_TIMEOUT:
5257+ /* No longer used. This is still here in case a mix of versions are used. */
5258+ break;
5259+
5260+ case WRAPPER_MSG_SERVICE_CONTROL_CODE:
5261+ try
5262+ {
5263+ int serviceControlCode = Integer.parseInt( msg );
5264+ if ( m_debug )
5265+ {
5266+ m_outDebug.println( getRes().getString(
5267+ "ServiceControlCode from Wrapper with code {0}",
5268+ new Integer( serviceControlCode ) ) );
5269+ }
5270+ WrapperServiceControlEvent event =
5271+ new WrapperServiceControlEvent( serviceControlCode );
5272+ fireWrapperEvent( event );
5273+ }
5274+ catch ( NumberFormatException e )
5275+ {
5276+ m_outError.println( getRes().getString(
5277+ "Encountered an Illegal ServiceControlCode from the Wrapper: {0}", msg ) );
5278+ }
5279+ break;
5280+
5281+ case WRAPPER_MSG_PAUSE:
5282+ try
5283+ {
5284+ int actionCode = Integer.parseInt( msg );
5285+ if ( m_debug )
5286+ {
5287+ m_outDebug.println( getRes().getString( "Pause from Wrapper with code {0}", new Integer( actionCode ) ) );
5288+ }
5289+ WrapperServicePauseEvent event =
5290+ new WrapperServicePauseEvent( actionCode );
5291+ fireWrapperEvent( event );
5292+ }
5293+ catch ( NumberFormatException e )
5294+ {
5295+ m_outError.println( getRes().getString(
5296+ "Encountered an Illegal ActionCode from the Wrapper: {0}", msg ) );
5297+ }
5298+ break;
5299+
5300+ case WRAPPER_MSG_RESUME:
5301+ try
5302+ {
5303+ int actionCode = Integer.parseInt( msg );
5304+ if ( m_debug )
5305+ {
5306+ m_outDebug.println( getRes().getString("Resume from Wrapper with code {0}", new Integer( actionCode ) ) );
5307+ }
5308+ WrapperServiceResumeEvent event =
5309+ new WrapperServiceResumeEvent( actionCode );
5310+ fireWrapperEvent( event );
5311+ }
5312+ catch ( NumberFormatException e )
5313+ {
5314+ m_outError.println( getRes().getString(
5315+ "Encountered an Illegal ActionCode from the Wrapper: {0}", msg ) );
5316+ }
5317+ break;
5318+
5319+ case WRAPPER_MSG_GC:
5320+ System.gc();
5321+ break;
5322+
5323+ case WRAPPER_MSG_PROPERTIES:
5324+ readProperties( msg );
5325+ break;
5326+
5327+ case WRAPPER_MSG_LOGFILE:
5328+ m_logFile = new File( msg );
5329+ WrapperLogFileChangedEvent event = new WrapperLogFileChangedEvent( m_logFile );
52855330 fireWrapperEvent( event );
5331+ break;
5332+
5333+ default:
5334+ // Ignore unknown messages
5335+ m_outInfo.println( getRes().getString(
5336+ "Wrapper code received an unknown packet type: {0}", new Integer( code ) ) );
5337+ break;
52865338 }
5287- catch ( NumberFormatException e )
5288- {
5289- m_outError.println( getRes().getString(
5290- "Encountered an Illegal ActionCode from the Wrapper: {0}", msg ) );
5291- }
5292- break;
5293-
5294- case WRAPPER_MSG_GC:
5295- System.gc();
5296- break;
5297-
5298- case WRAPPER_MSG_PROPERTIES:
5299- readProperties( msg );
5300- break;
5301-
5302- case WRAPPER_MSG_LOGFILE:
5303- m_logFile = new File( msg );
5304- WrapperLogFileChangedEvent event = new WrapperLogFileChangedEvent( m_logFile );
5305- fireWrapperEvent( event );
5306- break;
5307-
5308- default:
5309- // Ignore unknown messages
5310- m_outInfo.println( getRes().getString(
5311- "Wrapper code received an unknown packet type: {0}", new Integer( code ) ) );
5312- break;
53135339 }
53145340 }
5341+ catch ( SocketTimeoutException e )
5342+ {
5343+ if ( m_debug )
5344+ {
5345+ m_outDebug.println( getRes().getString( "Backend socket timed out. Attempting to continue. (SO_TIMEOUT={0}ms.)",
5346+ new Integer( m_backendSocket.getSoTimeout() ) ) );
5347+ }
5348+ }
53155349 }
53165350 if ( m_debug )
53175351 {
--- trunk/wrapper/src/c/wrapper_win.c (revision 165)
+++ trunk/wrapper/src/c/wrapper_win.c (revision 166)
@@ -411,10 +411,17 @@
411411 * filename: File to write to.
412412 * pid: pid to write in the file.
413413 */
414-int writePidFile(const TCHAR *filename, DWORD pid, int newUmask) {
414+int writePidFile(const TCHAR *filename, DWORD pid, int newUmask, int exclusive) {
415415 FILE *pid_fp = NULL;
416416 int old_umask;
417417
418+ if (getBooleanProperty(properties, TEXT("wrapper.pidfile.strict"), FALSE, FALSE) == TRUE &&
419+ exclusive == TRUE && file_exists(filename)) {
420+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_ERROR,
421+ TEXT("%d pid file, %s, already exists."), pid, filename);
422+ cleanUpPIDFilesOnExit = FALSE;
423+ return 1;
424+ }
418425 old_umask = _umask(newUmask);
419426 pid_fp = _tfopen(filename, TEXT("w"));
420427 _umask(old_umask);
@@ -1811,7 +1818,7 @@
18111818
18121819 /* If a java pid filename is specified then write the pid of the java process. */
18131820 if (wrapperData->javaPidFilename) {
1814- if (writePidFile(wrapperData->javaPidFilename, wrapperData->javaPID, wrapperData->javaPidFileUmask)) {
1821+ if (writePidFile(wrapperData->javaPidFilename, wrapperData->javaPID, wrapperData->javaPidFileUmask, FALSE)) {
18151822 log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_WARN,
18161823 TEXT("Unable to write the Java PID file: %s"), wrapperData->javaPidFilename);
18171824 }
@@ -1819,7 +1826,7 @@
18191826
18201827 /* If a java id filename is specified then write the id of the java process. */
18211828 if (wrapperData->javaIdFilename) {
1822- if (writePidFile(wrapperData->javaIdFilename, wrapperData->jvmRestarts, wrapperData->javaIdFileUmask)) {
1829+ if (writePidFile(wrapperData->javaIdFilename, wrapperData->jvmRestarts, wrapperData->javaIdFileUmask, FALSE)) {
18231830 log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_WARN,
18241831 TEXT("Unable to write the Java Id file: %s"), wrapperData->javaIdFilename);
18251832 }
@@ -3160,32 +3167,23 @@
31603167 #define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
31613168 #endif
31623169
3163-LSA_UNICODE_STRING InitLsaString(TCHAR* pwszString) {
3164- USHORT dwLen = 0;
3165- LSA_UNICODE_STRING pLsaString;
3170+void InitLsaString(PLSA_UNICODE_STRING LsaString, LPWSTR String) {
3171+ size_t StringLength;
31663172
3167- if ((pwszString != NULL) && ((dwLen = (USHORT)wcslen(pwszString)) > 0)) {
3168- pLsaString.Buffer = (WCHAR*)pwszString;
3169- }
3170- pLsaString.Length = dwLen * sizeof(wchar_t);
3171- pLsaString.MaximumLength= (dwLen+1) * sizeof(wchar_t);
3172- return pLsaString;
3173-}
3174-
3175-
3176-BOOL AllocWStrFromLSAStr(PWSTR *ppwstrTarget, LSA_UNICODE_STRING LsaStr) {
3177- *ppwstrTarget = (PWSTR)LocalAlloc(0,LsaStr.Length + sizeof(WCHAR));
3178- if (*ppwstrTarget == NULL) {
3179- return FALSE;
3173+ if (String == NULL) {
3174+ LsaString->Buffer = NULL;
3175+ LsaString->Length = 0;
3176+ LsaString->MaximumLength = 0;
3177+ return;
31803178 }
3181- memcpy(*ppwstrTarget,LsaStr.Buffer,LsaStr.Length);
3182- (*ppwstrTarget)[LsaStr.Length] = TEXT('\0');
31833179
3184- return TRUE;
3180+ StringLength = wcslen(String);
3181+ LsaString->Buffer = String;
3182+ LsaString->Length = (USHORT) StringLength * sizeof(WCHAR);
3183+ LsaString->MaximumLength=(USHORT)(StringLength+1) * sizeof(WCHAR);
31853184 }
31863185
3187-
3188-NTSTATUS OpenPolicy(TCHAR* ServerName, DWORD DesiredAccess, PLSA_HANDLE PolicyHandle) {
3186+NTSTATUS OpenPolicy(LPWSTR ServerName, DWORD DesiredAccess, PLSA_HANDLE PolicyHandle) {
31893187 LSA_OBJECT_ATTRIBUTES ObjectAttributes;
31903188 LSA_UNICODE_STRING ServerString;
31913189 PLSA_UNICODE_STRING Server = NULL;
@@ -3193,16 +3191,17 @@
31933191 ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes));
31943192
31953193 if (ServerName != NULL) {
3196- ServerString = InitLsaString(ServerName);
3194+ InitLsaString(&ServerString, ServerName);
31973195 Server = &ServerString;
31983196 }
31993197
3200- return LsaOpenPolicy(Server, &ObjectAttributes,
3201- DesiredAccess, PolicyHandle);
3198+ return LsaOpenPolicy(Server, &ObjectAttributes, DesiredAccess, PolicyHandle);
32023199 }
32033200
3201+
32043202 /*
32053203 * Checks if pc is part of Domain, workgroup or standalone
3204+ * @returns 1 if it's part of Domain, 2 for workgroup, 3 for stand alone, 0 if there was an error
32063205 */
32073206 int checkDomain() {
32083207 LSA_HANDLE PolicyHandle;
@@ -3210,31 +3209,55 @@
32103209 PPOLICY_PRIMARY_DOMAIN_INFO ppdiDomainInfo;
32113210 PWKSTA_INFO_100 pwkiWorkstationInfo;
32123211 DWORD netret;
3213- PWSTR ResName;
3212+ wchar_t* ResName;
32143213 int ret = 0;
32153214
32163215 netret = NetWkstaGetInfo(NULL, 100, (LPBYTE *)&pwkiWorkstationInfo);
3216+#ifdef _DEBUG
3217+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG, TEXT("checkDomain: NetWkstaGetInfo returned %d"), netret);
3218+#endif
32173219 if (netret == NERR_Success) {
32183220 status = OpenPolicy(NULL, GENERIC_READ | POLICY_VIEW_LOCAL_INFORMATION, &PolicyHandle);
3221+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG, TEXT("checkDomain: OpenPolicy returned %d\n"), status);
32193222 if (!status) {
3223+#ifdef _DEBUG
3224+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG, TEXT("checkDomain: LsaQueryInformationPolicy call ahead"));fflush(NULL);
3225+#endif
32203226 status = LsaQueryInformationPolicy(PolicyHandle, PolicyPrimaryDomainInformation, &ppdiDomainInfo);
3227+#ifdef _DEBUG
3228+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG, TEXT("checkDomain: LsaQueryInformationPolicy returned %d"), status);
3229+#endif
32213230 if (!status) {
3222- AllocWStrFromLSAStr(&ResName, ppdiDomainInfo->Name);
3223- if (ppdiDomainInfo->Sid) {
3224- ret = 1;
3225- } else {
3226- if (_tcsncmp(ResName, (LPWSTR)pwkiWorkstationInfo->wki100_computername,
3227- wcslen((LPWSTR)pwkiWorkstationInfo->wki100_computername))) {
3228- ret = 2;
3231+#ifdef _DEBUG
3232+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG,
3233+ TEXT("checkDomain: LsaQueryInformationPolicy:ppdiDomainInfo->maxlen = %d, len=%d, buffer=%s, strlen=%d"),
3234+ ppdiDomainInfo->Name.MaximumLength,ppdiDomainInfo->Name.Length ,ppdiDomainInfo->Name.Buffer, wcslen(ppdiDomainInfo->Name.Buffer));
3235+#endif
3236+ ResName = malloc((wcslen(ppdiDomainInfo->Name.Buffer) + 1 ) * sizeof(wchar_t));
3237+ if (ResName) {
3238+ _tcsncpy(ResName, ppdiDomainInfo->Name.Buffer, wcslen(ppdiDomainInfo->Name.Buffer) + 1);
3239+ if (ppdiDomainInfo->Sid) {
3240+ ret = 1;
32293241 } else {
3230- ret = 3;
3242+#ifdef _DEBUG
3243+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG,
3244+ TEXT("checkDomain: comparing %s vs. %s"), ResName,
3245+ pwkiWorkstationInfo->wki100_computername);
3246+#endif
3247+ if (_tcsncmp(ResName, pwkiWorkstationInfo->wki100_computername,
3248+ wcslen(pwkiWorkstationInfo->wki100_computername))) {
3249+ ret = 2;
3250+ } else {
3251+ ret = 3;
3252+ }
32313253 }
3254+ free(ResName);
32323255 }
3233- LocalFree(ResName);
3256+ LsaFreeMemory((LPVOID)ppdiDomainInfo);
32343257 }
3258+ LsaClose(PolicyHandle);
32353259 }
32363260 NetApiBufferFree(pwkiWorkstationInfo);
3237- LsaFreeMemory((LPVOID)ppdiDomainInfo);
32383261 }
32393262 return ret;
32403263 }
@@ -3252,15 +3275,30 @@
32523275 int k;
32533276
32543277 k = checkDomain();
3278+#ifdef _DEBUG
3279+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG, TEXT("checkDomain returns %d."), k);
3280+#endif
32553281 if (k > 0) {
32563282 if (k > 1) {
3283+#ifdef _DEBUG
3284+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG, TEXT("OpenPolicy call %s "), referencedDomainName);
3285+#endif
32573286 ntsResult = OpenPolicy(referencedDomainName, /* Name of the target system. */
32583287 POLICY_LOOKUP_NAMES | POLICY_CREATE_ACCOUNT, /* Desired access permissions. */
32593288 &lsahPolicyHandle); /*Receives the policy handle. */
3289+#ifdef _DEBUG
3290+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG, TEXT("OpenPolicy returns %d."), ntsResult);
3291+#endif
32603292 } else {
3293+#ifdef _DEBUG
3294+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG, TEXT("OpenPolicy call NULL."));
3295+#endif
32613296 ntsResult = OpenPolicy(NULL, /* Name of the target system. */
32623297 POLICY_LOOKUP_NAMES | POLICY_CREATE_ACCOUNT, /* Desired access permissions. */
32633298 &lsahPolicyHandle); /*Receives the policy handle. */
3299+#ifdef _DEBUG
3300+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG, TEXT("OpenPolicy returns %d."), ntsResult);
3301+#endif
32643302 }
32653303 if (ntsResult != STATUS_SUCCESS) {
32663304 /* An error occurred. Display it as a win32 error code. */
@@ -3284,29 +3322,39 @@
32843322 SID_NAME_USE eUse;
32853323 LPCTSTR formattedAccountName;
32863324
3325+#ifdef _DEBUG
3326+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG, TEXT("lookupname: %s"), lpszAccountName);
3327+#endif
32873328 if (_tcsstr(lpszAccountName, TEXT(".\\")) == lpszAccountName) {
32883329 formattedAccountName = lpszAccountName + 2;
32893330 } else {
32903331 formattedAccountName= lpszAccountName;
32913332 }
32923333
3334+#ifdef _DEBUG
3335+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG, TEXT("lookupname:formatedname %s"), formattedAccountName);
3336+#endif
3337+
32933338 cbReferencedDomainName = cbSid = 0;
3294- if (LookupAccountName(NULL, formattedAccountName, 0, &cbSid, 0, &cbReferencedDomainName, &eUse)) {
3339+ if (LookupAccountName(NULL, formattedAccountName, NULL, &cbSid, NULL, &cbReferencedDomainName, &eUse)) {
32953340 /* A straight success - that can't be... */
32963341 return 0;
32973342 }
32983343 lastError = GetLastError();
32993344 if (lastError != ERROR_INSUFFICIENT_BUFFER) {
33003345 /* Any error except the one above is fatal.. */
3301- log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_ERROR, TEXT("Failed to lookup the account (%s): %d - %s\n"), lpszAccountName, lastError, getLastErrorText());
3346+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_ERROR, TEXT("Failed to lookup the account (%s): %d - %s"), lpszAccountName, lastError, getLastErrorText());
33023347 return 0;
33033348 }
3349+#ifdef _DEBUG
3350+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG, TEXT("lookupname:cbSID %d ; cbDomain %d"), cbSid, cbReferencedDomainName);
3351+#endif
33043352 if (!(Sid = (PSID)malloc(cbSid))) {
33053353 outOfMemory(TEXT("WLN"), 1);
33063354 return 0;
33073355 }
33083356
3309- *referencedDomainName = (LPTSTR)malloc((cbReferencedDomainName + 1) * sizeof(TCHAR));
3357+ *referencedDomainName = (LPTSTR)calloc((cbReferencedDomainName ), sizeof(TCHAR));
33103358 if (!(*referencedDomainName)) {
33113359 LocalFree(Sid);
33123360 outOfMemory(TEXT("WLN"), 2);
@@ -3315,9 +3363,12 @@
33153363 if (!LookupAccountName(NULL, formattedAccountName, Sid, &cbSid, *referencedDomainName, &cbReferencedDomainName, &eUse)) {
33163364 free(*referencedDomainName);
33173365 free(Sid);
3318- log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_ERROR, TEXT("Failed to lookup the account (%s): %d - %s\n"), lpszAccountName, lastError, getLastErrorText());
3366+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_ERROR, TEXT("Failed to lookup the account (%s): %d - %s"), lpszAccountName, lastError, getLastErrorText());
33193367 return 0;
33203368 }
3369+#ifdef _DEBUG
3370+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG, TEXT("lookupname:cbreferencedDomain %s"), *referencedDomainName);
3371+#endif
33213372 return Sid;
33223373 }
33233374
@@ -3340,22 +3391,26 @@
33403391
33413392 AccountSID = wrapperLookupName(account, &referencedDomainName);
33423393
3343- if (AccountSID) {
3394+ if (AccountSID) {
33443395 if ((PolicyHandle = wrapperGetPolicyHandle(referencedDomainName)) != NULL) {
33453396 /* Create an LSA_UNICODE_STRING for the privilege names. */
33463397 pointer = malloc(sizeof(LSA_UNICODE_STRING));
3347- pointer[0] = InitLsaString(privileges);
3348-
3349- ntsResult = LsaAddAccountRights(PolicyHandle, /* An open policy handle. */
3350- AccountSID, /* The target SID. */
3351- pointer, /* The privileges. */
3352- counter); /* Number of privileges. */
3353- free(pointer);
3354- if (ntsResult == STATUS_SUCCESS) {
3355- retVal = FALSE;
3398+ if (pointer == NULL) {
3399+ outOfMemory(TEXT("WAP"), 1);
33563400 } else {
3357- log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_ERROR, TEXT("Failed to add Logon As Service Permission: %lu\n"), LsaNtStatusToWinError(ntsResult));
3401+ InitLsaString(pointer, privileges);
3402+ ntsResult = LsaAddAccountRights(PolicyHandle, /* An open policy handle. */
3403+ AccountSID, /* The target SID. */
3404+ pointer, /* The privileges. */
3405+ counter); /* Number of privileges. */
3406+ free(pointer);
3407+ if (ntsResult == STATUS_SUCCESS) {
3408+ retVal = FALSE;
3409+ } else {
3410+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_ERROR, TEXT("Failed to add Logon As Service Permission: %lu"), LsaNtStatusToWinError(ntsResult));
3411+ }
33583412 }
3413+ LsaClose(PolicyHandle);
33593414 }
33603415 free(AccountSID);
33613416 free(referencedDomainName);
@@ -6109,31 +6164,32 @@
61096164 rollLogs();
61106165 }
61116166
6112- /* Write pid and anchor files as requested. If they are the same file the file is
6113- * simply overwritten. */
61146167 cleanUpPIDFilesOnExit = TRUE;
6115- if (wrapperData->anchorFilename) {
6116- if (writePidFile(wrapperData->anchorFilename, wrapperData->wrapperPID, wrapperData->anchorFileUmask)) {
6168+ if (wrapperData->pidFilename) {
6169+ if (writePidFile(wrapperData->pidFilename, wrapperData->wrapperPID, wrapperData->pidFileUmask, TRUE)) {
61176170 log_printf
61186171 (WRAPPER_SOURCE_WRAPPER, LEVEL_FATAL,
6119- TEXT("ERROR: Could not write anchor file %s: %s"),
6120- wrapperData->anchorFilename, getLastErrorText());
6172+ TEXT("ERROR: Could not write pid file %s: %s"),
6173+ wrapperData->pidFilename, getLastErrorText());
61216174 appExit(1);
61226175 return; /* For clarity. */
61236176 }
61246177 }
6125- if (wrapperData->pidFilename) {
6126- if (writePidFile(wrapperData->pidFilename, wrapperData->wrapperPID, wrapperData->pidFileUmask)) {
6178+ /* Write pid and anchor files as requested. If they are the same file the file is
6179+ * simply overwritten. */
6180+ if (wrapperData->anchorFilename) {
6181+ if (writePidFile(wrapperData->anchorFilename, wrapperData->wrapperPID, wrapperData->anchorFileUmask, FALSE)) {
61276182 log_printf
61286183 (WRAPPER_SOURCE_WRAPPER, LEVEL_FATAL,
6129- TEXT("ERROR: Could not write pid file %s: %s"),
6130- wrapperData->pidFilename, getLastErrorText());
6184+ TEXT("ERROR: Could not write anchor file %s: %s"),
6185+ wrapperData->anchorFilename, getLastErrorText());
61316186 appExit(1);
61326187 return; /* For clarity. */
61336188 }
61346189 }
6190+
61356191 if (wrapperData->lockFilename) {
6136- if (writePidFile(wrapperData->lockFilename, wrapperData->wrapperPID, wrapperData->lockFileUmask)) {
6192+ if (writePidFile(wrapperData->lockFilename, wrapperData->wrapperPID, wrapperData->lockFileUmask, FALSE)) {
61376193 log_printf
61386194 (WRAPPER_SOURCE_WRAPPER, LEVEL_FATAL,
61396195 TEXT("ERROR: Could not write lock file %s: %s"),
@@ -6170,27 +6226,29 @@
61706226 /* Write pid and anchor files as requested. If they are the same file the file is
61716227 * simply overwritten. */
61726228 cleanUpPIDFilesOnExit = TRUE;
6173- if (wrapperData->anchorFilename) {
6174- if (writePidFile(wrapperData->anchorFilename, wrapperData->wrapperPID, wrapperData->anchorFileUmask)) {
6229+ if (wrapperData->pidFilename) {
6230+ if (writePidFile(wrapperData->pidFilename, wrapperData->wrapperPID, wrapperData->pidFileUmask, TRUE)) {
61756231 log_printf
61766232 (WRAPPER_SOURCE_WRAPPER, LEVEL_FATAL,
6177- TEXT("ERROR: Could not write anchor file %s: %s"),
6178- wrapperData->anchorFilename, getLastErrorText());
6233+ TEXT("ERROR: Could not write pid file %s: %s"),
6234+ wrapperData->pidFilename, getLastErrorText());
61796235 appExit(1);
61806236 return; /* For clarity. */
61816237 }
61826238 }
6183- if (wrapperData->pidFilename) {
6184- if (writePidFile(wrapperData->pidFilename, wrapperData->wrapperPID, wrapperData->pidFileUmask)) {
6239+
6240+ if (wrapperData->anchorFilename) {
6241+ if (writePidFile(wrapperData->anchorFilename, wrapperData->wrapperPID, wrapperData->anchorFileUmask, FALSE)) {
61856242 log_printf
61866243 (WRAPPER_SOURCE_WRAPPER, LEVEL_FATAL,
6187- TEXT("ERROR: Could not write pid file %s: %s"),
6188- wrapperData->pidFilename, getLastErrorText());
6244+ TEXT("ERROR: Could not write anchor file %s: %s"),
6245+ wrapperData->anchorFilename, getLastErrorText());
61896246 appExit(1);
61906247 return; /* For clarity. */
61916248 }
61926249 }
61936250
6251+
61946252 /* Prepare the service table */
61956253 serviceTable[0].lpServiceName = wrapperData->serviceName;
61966254 serviceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)wrapperServiceMain;
@@ -6292,10 +6350,15 @@
62926350 outClosed = TRUE;
62936351 }
62946352 /* currentBlockAvail is already in bytes! */
6295- if (ret && (currentBlockAvail > 0) && (currentBlockAvail < 512 * sizeof(TCHAR))) {
6353+ if (ret && (currentBlockAvail > 0)) {
6354+ if (currentBlockAvail < 512 * sizeof(TCHAR)) {
6355+ writeOut = 512 * sizeof(TCHAR);
6356+ } else {
6357+ writeOut = currentBlockAvail;
6358+ }
62966359 /* Clean the buffer before each read, as we don't want old stuff */
62976360 memset(outbuf,0, sizeof(outbuf));
6298- if (ReadFile(out, outbuf, currentBlockAvail, &outRead, NULL) == TRUE) {
6361+ if (ReadFile(out, outbuf, writeOut, &outRead, NULL) == TRUE) {
62996362 /* if the message we just read in, doesn't have a new line, it means, that we most likely
63006363 got the secondary process prompting sth. */
63016364 if (outbuf[_tcslen(outbuf) - 1] != TEXT('\n')) {
--- trunk/wrapper/src/c/wrapper.c (revision 165)
+++ trunk/wrapper/src/c/wrapper.c (revision 166)
@@ -187,6 +187,16 @@
187187 return buildTM;
188188 }
189189
190+int file_exists(const TCHAR * filename) {
191+ FILE * file;
192+ if ((file = _tfopen(filename, TEXT("r")))) {
193+ fclose(file);
194+ return TRUE;
195+ }
196+ return FALSE;
197+}
198+
199+
190200 struct tm wrapperGetReleaseTime() {
191201 return getInfoTime(wrapperReleaseDate, wrapperReleaseTime);
192202 }
@@ -2170,6 +2180,7 @@
21702180 wrapperData->outputFilterCount = 0;
21712181 wrapperData->confDir = NULL;
21722182 wrapperData->umask = -1;
2183+ wrapperData->language = NULL;
21732184 #ifdef WIN32
21742185 if (!(tickMutexHandle = CreateMutex(NULL, FALSE, NULL))) {
21752186 printf("Failed to create tick mutex. %s\n", getLastErrorText());
@@ -6015,7 +6026,7 @@
60156026
60166027 /* Allocate the correct amount of memory */
60176028 *stringsPtr = malloc((*length) * sizeof **stringsPtr );
6018- if (!stringsPtr) {
6029+ if (!(*stringsPtr)) {
60196030 outOfMemory(TEXT("WBJCA"), 1);
60206031 return TRUE;
60216032 }
@@ -7149,6 +7160,12 @@
71497160
71507161 #endif
71517162
7163+ if (_tcscmp(wrapperVersionRoot, getStringProperty(properties, TEXT("wrapper.script.version"), wrapperVersionRoot)) != 0) {
7164+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_WARN,
7165+ TEXT("The version of the script (%s) doesn't match the version of this Wrapper (%s). This might cause some problems"),
7166+ getStringProperty(properties, TEXT("wrapper.script.version"), wrapperVersionRoot), wrapperVersionRoot);
7167+ }
7168+
71527169 wrapperData->configured = TRUE;
71537170
71547171 return FALSE;
--- trunk/wrapper/src/c/wrapper_unix.c (revision 165)
+++ trunk/wrapper/src/c/wrapper_unix.c (revision 166)
@@ -167,10 +167,17 @@
167167 * filename: File to write to.
168168 * pid: pid to write in the file.
169169 */
170-int writePidFile(const TCHAR *filename, DWORD pid, int newUmask) {
170+int writePidFile(const TCHAR *filename, DWORD pid, int newUmask, int exclusive) {
171171 FILE *pid_fp = NULL;
172172 int old_umask;
173173
174+ if (getBooleanProperty(properties, TEXT("wrapper.pidfile.strict"), FALSE, FALSE) == TRUE &&
175+ exclusive == TRUE && file_exists(filename)) {
176+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_ERROR,
177+ TEXT("%d pid file, %s, already exists."), pid, filename);
178+ return 1;
179+ }
180+
174181 old_umask = umask(newUmask);
175182 pid_fp = _tfopen(filename, TEXT("w"));
176183 umask(old_umask);
@@ -1253,7 +1260,7 @@
12531260
12541261 /* If a java pid filename is specified then write the pid of the java process. */
12551262 if (wrapperData->javaPidFilename) {
1256- if (writePidFile(wrapperData->javaPidFilename, wrapperData->javaPID, wrapperData->javaPidFileUmask)) {
1263+ if (writePidFile(wrapperData->javaPidFilename, wrapperData->javaPID, wrapperData->javaPidFileUmask, FALSE)) {
12571264 log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_WARN,
12581265 TEXT("Unable to write the Java PID file: %s"), wrapperData->javaPidFilename);
12591266 }
@@ -1261,7 +1268,7 @@
12611268
12621269 /* If a java id filename is specified then write the pid of the java process. */
12631270 if (wrapperData->javaIdFilename) {
1264- if (writePidFile(wrapperData->javaIdFilename, wrapperData->jvmRestarts, wrapperData->javaIdFileUmask)) {
1271+ if (writePidFile(wrapperData->javaIdFilename, wrapperData->jvmRestarts, wrapperData->javaIdFileUmask, FALSE)) {
12651272 log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_WARN,
12661273 TEXT("Unable to write the Java Id file: %s"), wrapperData->javaIdFilename);
12671274 }
@@ -1825,10 +1832,32 @@
18251832 rollLogs();
18261833 }
18271834
1835+ if (wrapperData->pidFilename) {
1836+ if (writePidFile(wrapperData->pidFilename, wrapperData->wrapperPID, wrapperData->pidFileUmask, TRUE)) {
1837+ log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_FATAL,
1838+ TEXT("ERROR: Could not write pid file %s: %s"),
1839+ wrapperData->pidFilename, getLastErrorText());
1840+ /* Common wrapper cleanup code. */
1841+ wrapperDispose();
1842+#if defined(UNICODE)
1843+ for (i = 0; i < argc; i++) {
1844+ if (argv[i]) {
1845+ free(argv[i]);
1846+ }
1847+ }
1848+ if (argv) {
1849+ free(argv);
1850+ }
1851+#endif
1852+ exit(1);
1853+ return 1; /* For compiler. */
1854+ }
1855+ }
1856+
18281857 /* Write pid and anchor files as requested. If they are the same file the file is
18291858 * simply overwritten. */
18301859 if (wrapperData->anchorFilename) {
1831- if (writePidFile(wrapperData->anchorFilename, wrapperData->wrapperPID, wrapperData->anchorFileUmask)) {
1860+ if (writePidFile(wrapperData->anchorFilename, wrapperData->wrapperPID, wrapperData->anchorFileUmask, FALSE)) {
18321861 log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_FATAL,
18331862 TEXT("ERROR: Could not write anchor file %s: %s"),
18341863 wrapperData->anchorFilename, getLastErrorText());
@@ -1836,17 +1865,9 @@
18361865 return 1; /* For compiler. */
18371866 }
18381867 }
1839- if (wrapperData->pidFilename) {
1840- if (writePidFile(wrapperData->pidFilename, wrapperData->wrapperPID, wrapperData->pidFileUmask)) {
1841- log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_FATAL,
1842- TEXT("ERROR: Could not write pid file %s: %s"),
1843- wrapperData->pidFilename, getLastErrorText());
1844- appExit(1, argc, argv);
1845- return 1; /* For compiler. */
1846- }
1847- }
1868+
18481869 if (wrapperData->lockFilename) {
1849- if (writePidFile(wrapperData->lockFilename, wrapperData->wrapperPID, wrapperData->lockFileUmask)) {
1870+ if (writePidFile(wrapperData->lockFilename, wrapperData->wrapperPID, wrapperData->lockFileUmask, FALSE)) {
18501871 /* This will fail if the user is running as a user without full privileges.
18511872 * To make things easier for user configuration, this is ignored if sufficient
18521873 * privileges do not exist. */
--- trunk/wrapper/src/c/wrapper.h (revision 165)
+++ trunk/wrapper/src/c/wrapper.h (revision 166)
@@ -957,4 +957,6 @@
957957 extern void wrapperStoppedSignaled();
958958 extern void wrapperStartPendingSignaled(int waitHint);
959959 extern void wrapperStartedSignaled();
960+extern int file_exists(const TCHAR * filename);
961+
960962 #endif
--- trunk/wrapper/src/c/logger.c (revision 165)
+++ trunk/wrapper/src/c/logger.c (revision 166)
@@ -429,7 +429,7 @@
429429 free(workLogFileName);
430430 workLogFileName = NULL;
431431 }
432- if (loginfoSourceName != defaultLoginfoSourceName) {
432+ if (loginfoSourceName != defaultLoginfoSourceName && loginfoSourceName != NULL) {
433433 free(loginfoSourceName);
434434 loginfoSourceName = NULL;
435435 }
@@ -1137,7 +1137,9 @@
11371137 size_t size;
11381138 if (event_source_name != NULL) {
11391139 if (loginfoSourceName != defaultLoginfoSourceName) {
1140- free(loginfoSourceName);
1140+ if (loginfoSourceName != NULL) {
1141+ free(loginfoSourceName);
1142+ }
11411143 }
11421144 #ifdef WIN32
11431145 size = sizeof(TCHAR) * (_tcslen(event_source_name) + 1);
@@ -1151,7 +1153,7 @@
11511153 return;
11521154 }
11531155 #ifdef WIN32
1154- _tcsncpy(loginfoSourceName, event_source_name, _tcslen(event_source_name));
1156+ _tcsncpy(loginfoSourceName, event_source_name, _tcslen(event_source_name) + 1);
11551157 if (_tcslen(loginfoSourceName) > 32) {
11561158 loginfoSourceName[32] = TEXT('\0');
11571159 }
--- trunk/wrapper/src/c/property.c (revision 165)
+++ trunk/wrapper/src/c/property.c (revision 166)
@@ -1781,6 +1781,9 @@
17811781 setInnerProperty(property, propertyValueTrim);
17821782 }
17831783
1784+ if (property->value == NULL) {
1785+ return NULL;
1786+ }
17841787 /* Store the final flag */
17851788 property->finalValue = finalValue;
17861789
--- trunk/wrapper/src/c/wrapperinfo.c.in (revision 165)
+++ trunk/wrapper/src/c/wrapperinfo.c.in (revision 166)
@@ -28,7 +28,7 @@
2828 TCHAR *wrapperBits = TEXT("@bits@");
2929 TCHAR *wrapperArch = TEXT("@dist.arch@");
3030 TCHAR *wrapperOS = TEXT("@dist.os@");
31-TCHAR *wrapperReleaseDate = TEXT("20111201");
31+TCHAR *wrapperReleaseDate = TEXT("20120209");
3232 TCHAR *wrapperReleaseTime = TEXT("0000");
3333 TCHAR *wrapperBuildDate = TEXT("@build.date@");
3434 TCHAR *wrapperBuildTime = TEXT("@build.time@");
--- trunk/wrapper/src/conf/wrapper.conf.in (revision 165)
+++ trunk/wrapper/src/conf/wrapper.conf.in (revision 166)
@@ -117,6 +117,9 @@
117117 # Allow for the use of non-contiguous numbered properties
118118 wrapper.ignore_sequence_gaps=TRUE
119119
120+# Do not start if the pid file already exists.
121+wrapper.pidfile.strict=TRUE
122+
120123 # Title to use when running as a console
121124 wrapper.console.title=@app.long.name@
122125
--- trunk/wrapper/src/bin/QueryApp-NT.bat.in (revision 165)
+++ trunk/wrapper/src/bin/QueryApp-NT.bat.in (revision 166)
@@ -16,7 +16,7 @@
1616
1717 rem -----------------------------------------------------------------------------
1818 rem These settings can be modified to fit the needs of your application
19-rem Optimized for use with version 3.5.14-a of the Wrapper.
19+rem Optimized for use with version 3.5.14 of the Wrapper.
2020
2121 rem The base name for the Wrapper binary.
2222 set _WRAPPER_BASE=wrapper
--- trunk/wrapper/src/bin/StopApp-NT.bat.in (revision 165)
+++ trunk/wrapper/src/bin/StopApp-NT.bat.in (revision 166)
@@ -16,7 +16,7 @@
1616
1717 rem -----------------------------------------------------------------------------
1818 rem These settings can be modified to fit the needs of your application
19-rem Optimized for use with version 3.5.14-a of the Wrapper.
19+rem Optimized for use with version 3.5.14 of the Wrapper.
2020
2121 rem The base name for the Wrapper binary.
2222 set _WRAPPER_BASE=wrapper
--- trunk/wrapper/src/bin/InstallApp-NT.bat.in (revision 165)
+++ trunk/wrapper/src/bin/InstallApp-NT.bat.in (revision 166)
@@ -16,7 +16,7 @@
1616
1717 rem -----------------------------------------------------------------------------
1818 rem These settings can be modified to fit the needs of your application
19-rem Optimized for use with version 3.5.14-a of the Wrapper.
19+rem Optimized for use with version 3.5.14 of the Wrapper.
2020
2121 rem The base name for the Wrapper binary.
2222 set _WRAPPER_BASE=wrapper
--- trunk/wrapper/src/bin/sh.script.in (revision 165)
+++ trunk/wrapper/src/bin/sh.script.in (revision 166)
@@ -16,7 +16,7 @@
1616
1717 #-----------------------------------------------------------------------------
1818 # These settings can be modified to fit the needs of your application
19-# Optimized for use with version 3.5.14-a of the Wrapper.
19+# Optimized for use with version 3.5.14 of the Wrapper.
2020
2121 # Application
2222 APP_NAME="@app.name@"
@@ -757,7 +757,7 @@
757757 prepAdditionalParams "$@"
758758
759759 # The string passed to eval must handles spaces in paths correctly.
760- COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" wrapper.daemonize=TRUE $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP $ADDITIONAL_PARA"
760+ COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" wrapper.daemonize=TRUE $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.14 $ADDITIONAL_PARA"
761761 eval $COMMAND_LINE
762762 else
763763 eval echo `gettext '$APP_LONG_NAME is already running.'`
@@ -780,7 +780,7 @@
780780 prepAdditionalParams "$@"
781781
782782 # The string passed to eval must handles spaces in paths correctly.
783- COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" $ANCHORPROP $STATUSPROP $COMMANDPROP $LOCKPROP $ADDITIONAL_PARA"
783+ COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" $ANCHORPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.14 $ADDITIONAL_PARA"
784784 eval $COMMAND_LINE
785785 else
786786 eval echo `gettext '$APP_LONG_NAME is already running.'`
@@ -902,7 +902,7 @@
902902 prepAdditionalParams "$@"
903903
904904 # The string passed to eval must handles spaces in paths correctly.
905- COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" wrapper.daemonize=TRUE $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP $ADDITIONAL_PARA"
905+ COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" wrapper.daemonize=TRUE $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.14 $ADDITIONAL_PARA"
906906 eval $COMMAND_LINE
907907 else
908908 eval echo `gettext '$APP_LONG_NAME is already running.'`
--- trunk/wrapper/src/bin/UninstallApp-NT.bat.in (revision 165)
+++ trunk/wrapper/src/bin/UninstallApp-NT.bat.in (revision 166)
@@ -16,7 +16,7 @@
1616
1717 rem -----------------------------------------------------------------------------
1818 rem These settings can be modified to fit the needs of your application
19-rem Optimized for use with version 3.5.14-a of the Wrapper.
19+rem Optimized for use with version 3.5.14 of the Wrapper.
2020
2121 rem The base name for the Wrapper binary.
2222 set _WRAPPER_BASE=wrapper
--- trunk/wrapper/src/bin/AppTemplate.bat.in (revision 165)
+++ trunk/wrapper/src/bin/AppTemplate.bat.in (revision 166)
@@ -16,7 +16,7 @@
1616
1717 rem -----------------------------------------------------------------------------
1818 rem These settings can be modified to fit the needs of your application
19-rem Optimized for use with version 3.5.14-a of the Wrapper.
19+rem Optimized for use with version 3.5.14 of the Wrapper.
2020
2121 rem The base name for the Wrapper binary.
2222 set _WRAPPER_BASE=wrapper
--- trunk/wrapper/src/bin/PauseApp-NT.bat.in (revision 165)
+++ trunk/wrapper/src/bin/PauseApp-NT.bat.in (revision 166)
@@ -16,7 +16,7 @@
1616
1717 rem -----------------------------------------------------------------------------
1818 rem These settings can be modified to fit the needs of your application
19-rem Optimized for use with version 3.5.14-a of the Wrapper.
19+rem Optimized for use with version 3.5.14 of the Wrapper.
2020
2121 rem The base name for the Wrapper binary.
2222 set _WRAPPER_BASE=wrapper
--- trunk/wrapper/src/bin/StartApp-NT.bat.in (revision 165)
+++ trunk/wrapper/src/bin/StartApp-NT.bat.in (revision 166)
@@ -16,7 +16,7 @@
1616
1717 rem -----------------------------------------------------------------------------
1818 rem These settings can be modified to fit the needs of your application
19-rem Optimized for use with version 3.5.14-a of the Wrapper.
19+rem Optimized for use with version 3.5.14 of the Wrapper.
2020
2121 rem The base name for the Wrapper binary.
2222 set _WRAPPER_BASE=wrapper
--- trunk/wrapper/src/bin/AppCommand.bat.in (revision 165)
+++ trunk/wrapper/src/bin/AppCommand.bat.in (revision 166)
@@ -16,7 +16,7 @@
1616
1717 rem -----------------------------------------------------------------------------
1818 rem These settings can be modified to fit the needs of your application
19-rem Optimized for use with version 3.5.14-a of the Wrapper.
19+rem Optimized for use with version 3.5.14 of the Wrapper.
2020
2121 rem The base name for the Wrapper binary.
2222 set _WRAPPER_BASE=wrapper
@@ -63,16 +63,16 @@
6363 :search
6464
6565 set _WRAPPER_EXE=%_WRAPPER_L_EXE%
66-if not exist "%_WRAPPER_EXE%" (
67- set _WRAPPER_EXE=%_REALPATH%%_WRAPPER_BASE%.exe
68-) else if not exist "%_WRAPPER_EXE%" (
69- echo Unable to locate a Wrapper executable using any of the following names:
70- echo %_WRAPPER_L_EXE%
71- echo %_WRAPPER_EXE%
72- pause
73- goto :eof
74-)
66+if exist "%_WRAPPER_EXE%" goto conf
67+set _WRAPPER_EXE=%_REALPATH%%_WRAPPER_BASE%.exe
68+if exist "%_WRAPPER_EXE%" goto conf
69+echo Unable to locate a Wrapper executable using any of the following names:
70+echo %_WRAPPER_L_EXE%
71+echo %_WRAPPER_EXE%
72+pause
73+goto :eof
7574
75+:conf
7676 if not [%_FIXED_COMMAND%]==[] (
7777 set _COMMAND=%_FIXED_COMMAND%
7878 ) else (
--- trunk/wrapper/src/bin/App.bat.in (revision 165)
+++ trunk/wrapper/src/bin/App.bat.in (revision 166)
@@ -16,7 +16,7 @@
1616
1717 rem -----------------------------------------------------------------------------
1818 rem These settings can be modified to fit the needs of your application
19-rem Optimized for use with version 3.5.14-a of the Wrapper.
19+rem Optimized for use with version 3.5.14 of the Wrapper.
2020
2121 rem The base name for the Wrapper binary.
2222 set _WRAPPER_BASE=wrapper
--- trunk/wrapper/src/bin/ResumeApp-NT.bat.in (revision 165)
+++ trunk/wrapper/src/bin/ResumeApp-NT.bat.in (revision 166)
@@ -16,7 +16,7 @@
1616
1717 rem -----------------------------------------------------------------------------
1818 rem These settings can be modified to fit the needs of your application
19-rem Optimized for use with version 3.5.14-a of the Wrapper.
19+rem Optimized for use with version 3.5.14 of the Wrapper.
2020
2121 rem The base name for the Wrapper binary.
2222 set _WRAPPER_BASE=wrapper
--- trunk/wrapper/src/bin/AppTemplatePassThrough.bat.in (revision 165)
+++ trunk/wrapper/src/bin/AppTemplatePassThrough.bat.in (revision 166)
@@ -16,7 +16,7 @@
1616
1717 rem -----------------------------------------------------------------------------
1818 rem These settings can be modified to fit the needs of your application
19-rem Optimized for use with version 3.5.14-a of the Wrapper.
19+rem Optimized for use with version 3.5.14 of the Wrapper.
2020
2121 rem The base name for the Wrapper binary.
2222 set _WRAPPER_BASE=wrapper
--- trunk/wrapper/README_en.txt (revision 165)
+++ trunk/wrapper/README_en.txt (revision 166)
@@ -1,5 +1,5 @@
11 -----------------------------------------------------------------------------
2-Java Service Wrapper Community Edition 3.5.14-a
2+Java Service Wrapper Community Edition 3.5.14
33 Copyright (C) 1999-2011 Tanuki Software, Ltd. All Rights Reserved.
44 http://wrapper.tanukisoftware.com
55 -----------------------------------------------------------------------------
旧リポジトリブラウザで表示