Some services in my stacks need creds to be passed into the container during runtime (via secrets preferably) so that it can access external resources. Basically, the process needs to be running under the user so that it can authenticate.
In my entrypoint script, I have functions defined to initialize the user, grant the proper perms, etc. Now - I am able to assign this user to a service, and when the service runs, it is able to authenticate remotely. Without defining this user in the dockerfile/during buildtime.
However, not all apps can be run as services, and not all apps are built to accept creds to auth with for remote shares (nor can I access the source code). IE. in the container, first running a net use \ip\dir and successfully authenticating, setting it to a drive letter, and defining the path using the new drive in the services config file still fails (all with the same user, ContainerAdmin). To get around this, I am trying to start the process as a different user - the one passed in via secrets and initialized during entrypoint execution.
(I am aware that I can SMB global map the share on the host machine using the credentials and then bind mount that drive letter into the container in the compose. However this approach requires more setup on the host level)
Both of these functions fail when passing in creds of a local user, but not when run as the ContainerAdmin (ie. not passing those in). I have also tried opening up a new shell under that user first and then passing in the true call to no avail:
Start-Process -FilePath $path -ArgumentList $args -Credential $creds
and
psexec -u $user -p $pass $path $args (with any flags, including the services dns name as a remote machine, host machine name/IP, IP of the service on the docker network, etc)
I have tried every iteration of $user, including āusernameā, ā.\usernameā, ā$env:computername\usernameā, āBUILTIN\usernameā. when creating a pscredentials object the pass is converted to secure string as well. This user exists on the host machine and the remote target. There is no UAC in containers to my knowledge. I have given this user full modify access, as well as the following perms using secedit:
SeServiceLogonRight
SeBatchLogonRight
SeImpersonatePrivilege
SeDelegateSessionUserImpersonatePrivilege
SeInteractiveLogonRight
SeNetworkLogonRight
SeAssignPrimaryTokenPrivilege
Using start-process - when querying the containers event log, I can see logon event errors being thrown. The exit code is (0xc0000142). I need help in troubleshooting this further to be honest.
Using psexec, it fails with a āhandle not foundā and error code -1073741502 (which is the same in hex as the one above). When using psexec and passing in the -d flag, it says it started the process and spits out a PID, but running a tasklist -v right after shows nothing is actually running (and the app isnt generating logs so it was never ran).
I am at my wits end here. There has to be a way to do thisā¦ what am I missing? Anyone get this to work?
The super hacky solution I am thinking is to make a service in Go that literally just runs a given exe with parameters and slap that in the image.