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.
Commit
9c2a5c097b7718f010032388013b05adeea4940a
Parent
e0199bfc4339226…
1 file changed
+6
-1
+6
-1
| --- src/winhttp.c | ||
| +++ src/winhttp.c | ||
| @@ -688,10 +688,15 @@ | ||
| 688 | 688 | } |
| 689 | 689 | /* Process service creation specific options. */ |
| 690 | 690 | if( !zDisplay ){ |
| 691 | 691 | zDisplay = zSvcName; |
| 692 | 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 | + } | |
| 693 | 698 | if( zStart ){ |
| 694 | 699 | if( strncmp(zStart, "auto", strlen(zStart))==0 ){ |
| 695 | 700 | dwStartType = SERVICE_AUTO_START; |
| 696 | 701 | }else if( strncmp(zStart, "manual", strlen(zStart))==0 ){ |
| 697 | 702 | dwStartType = SERVICE_DEMAND_START; |
| @@ -736,11 +741,11 @@ | ||
| 736 | 741 | SERVICE_ERROR_NORMAL, /* Error control */ |
| 737 | 742 | fossil_utf8_to_unicode(blob_str(&binPath)), /* Binary path */ |
| 738 | 743 | NULL, /* Load ordering group */ |
| 739 | 744 | NULL, /* Tag value */ |
| 740 | 745 | NULL, /* Service dependencies */ |
| 741 | - fossil_utf8_to_unicode(zUsername), /* Service account */ | |
| 746 | + zUsername ? fossil_utf8_to_unicode(zUsername) : 0, /* Account */ | |
| 742 | 747 | fossil_utf8_to_unicode(zPassword) /* Account password */ |
| 743 | 748 | ); |
| 744 | 749 | if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); |
| 745 | 750 | /* Set the service description. */ |
| 746 | 751 | ChangeServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION, &svcDescr); |
| 747 | 752 |
| --- 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 |