Could use some help converting std:wstring to a LSA_UNICODE string to close SERVER-1227 Make installService grant the "Login as a Service" right if necessary to the user that is running the service

28 views
Skip to first unread message

Justin Dearing

unread,
Jan 15, 2012, 10:06:53 PM1/15/12
to mongodb-dev
Hey,

I'm on cusp of submitting a patch for that bug, but at my wits end. I made a working example of how to do it this afternoon: https://github.com/zippy1981/ntrights However, when I went to make the changes to ntservice.cpp, I discovered that the small difference between wchar_t* and std::wstring was not very small indeed.

I asked my exact question here: http://stackoverflow.com/questions/8875359/how-do-i-convert-a-stdwstring-to-an-lsa-unicode-string If I can solve that I'll have working code.

Thanks  in advance for any help,

Justin Dearing

Tad Marshall

unread,
Jan 16, 2012, 8:14:58 AM1/16/12
to mongo...@googlegroups.com

Hi Justin,

 

If you want to check your current changes (that crash) in ntservice.cpp into a branch on your mongodb fork, I can look at it and suggest changes.  That seems easier than operating indirectly through a stackoverflow question.

 

I think the answer you got on stackoverflow is correct ... .c_str() is giving you a buffer that is destroyed on exit from the function, so if you want to use a subroutine to create the LSA_UNICODE_STRING then you need to allocate memory yourself for the string's actual buffer.  As the other answer said, this gets ugly because of buffer ownership issues, prompting the excessive RAII example given.  My approach would be to write less code and just make sure that your buffer is valid when it needs to be and is freed when you are done with it.

 

Check in your code to your fork on a new temporary branch, post the branch name and I'll post suggested changes ... if you want.

 

Tad Marshall

 


--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To post to this group, send email to mongo...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-dev...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-dev?hl=en.

Tad Marshall

unread,
Jan 16, 2012, 8:36:15 AM1/16/12
to mongo...@googlegroups.com

Hi Justin,

 

I added a comment to the SERVER-1227 Jira ticket ... https://jira.mongodb.org/browse/SERVER-1227?focusedCommentId=80078#comment-80078 .  Just FYI ...

 

Tad Marshall

 


From: mongo...@googlegroups.com [mailto:mongo...@googlegroups.com] On Behalf Of Justin Dearing
Sent: Sunday, January 15, 2012 10:07 PM
To: mongodb-dev
Subject: [mongodb-dev] Could use some help converting std:wstring to a LSA_UNICODE string to close SERVER-1227 Make installService grant the "Login as a Service" right if necessary to the user that is running the service

 

Hey,

--

Reply all
Reply to author
Forward
0 new messages