Fossil SCM

Correct option handling for the 'winsrv create' command so that the default user name is NULL and the default password is an empty string when passed to the Win32 CreateServiceW API.

mistachkin 2014-08-01 06:13 trunk
Commit 9c2a5c097b7718f010032388013b05adeea4940a
1 file changed +6 -1
+6 -1
--- src/winhttp.c
+++ src/winhttp.c
@@ -688,10 +688,15 @@
688688
}
689689
/* Process service creation specific options. */
690690
if( !zDisplay ){
691691
zDisplay = zSvcName;
692692
}
693
+ /* Per MSDN, the password parameter cannot be NULL. Must use empty
694
+ ** string instead (i.e. in the call to CreateServiceW). */
695
+ if( !zPassword ){
696
+ zPassword = "";
697
+ }
693698
if( zStart ){
694699
if( strncmp(zStart, "auto", strlen(zStart))==0 ){
695700
dwStartType = SERVICE_AUTO_START;
696701
}else if( strncmp(zStart, "manual", strlen(zStart))==0 ){
697702
dwStartType = SERVICE_DEMAND_START;
@@ -736,11 +741,11 @@
736741
SERVICE_ERROR_NORMAL, /* Error control */
737742
fossil_utf8_to_unicode(blob_str(&binPath)), /* Binary path */
738743
NULL, /* Load ordering group */
739744
NULL, /* Tag value */
740745
NULL, /* Service dependencies */
741
- fossil_utf8_to_unicode(zUsername), /* Service account */
746
+ zUsername ? fossil_utf8_to_unicode(zUsername) : 0, /* Account */
742747
fossil_utf8_to_unicode(zPassword) /* Account password */
743748
);
744749
if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
745750
/* Set the service description. */
746751
ChangeServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION, &svcDescr);
747752
--- src/winhttp.c
+++ src/winhttp.c
@@ -688,10 +688,15 @@
688 }
689 /* Process service creation specific options. */
690 if( !zDisplay ){
691 zDisplay = zSvcName;
692 }
 
 
 
 
 
693 if( zStart ){
694 if( strncmp(zStart, "auto", strlen(zStart))==0 ){
695 dwStartType = SERVICE_AUTO_START;
696 }else if( strncmp(zStart, "manual", strlen(zStart))==0 ){
697 dwStartType = SERVICE_DEMAND_START;
@@ -736,11 +741,11 @@
736 SERVICE_ERROR_NORMAL, /* Error control */
737 fossil_utf8_to_unicode(blob_str(&binPath)), /* Binary path */
738 NULL, /* Load ordering group */
739 NULL, /* Tag value */
740 NULL, /* Service dependencies */
741 fossil_utf8_to_unicode(zUsername), /* Service account */
742 fossil_utf8_to_unicode(zPassword) /* Account password */
743 );
744 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
745 /* Set the service description. */
746 ChangeServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION, &svcDescr);
747
--- src/winhttp.c
+++ src/winhttp.c
@@ -688,10 +688,15 @@
688 }
689 /* Process service creation specific options. */
690 if( !zDisplay ){
691 zDisplay = zSvcName;
692 }
693 /* Per MSDN, the password parameter cannot be NULL. Must use empty
694 ** string instead (i.e. in the call to CreateServiceW). */
695 if( !zPassword ){
696 zPassword = "";
697 }
698 if( zStart ){
699 if( strncmp(zStart, "auto", strlen(zStart))==0 ){
700 dwStartType = SERVICE_AUTO_START;
701 }else if( strncmp(zStart, "manual", strlen(zStart))==0 ){
702 dwStartType = SERVICE_DEMAND_START;
@@ -736,11 +741,11 @@
741 SERVICE_ERROR_NORMAL, /* Error control */
742 fossil_utf8_to_unicode(blob_str(&binPath)), /* Binary path */
743 NULL, /* Load ordering group */
744 NULL, /* Tag value */
745 NULL, /* Service dependencies */
746 zUsername ? fossil_utf8_to_unicode(zUsername) : 0, /* Account */
747 fossil_utf8_to_unicode(zPassword) /* Account password */
748 );
749 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
750 /* Set the service description. */
751 ChangeServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION, &svcDescr);
752

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button