Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^5: Private temporal files on Windows

by BrowserUk (Patriarch)
on Dec 19, 2014 at 12:37 UTC ( [id://1110847]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Private temporal files on Windows
in thread Private temporal files on Windows

Also, a minor issue I have found with extprog is that a console window pops up briefly. Besides the visual ugliness what really worries me is if that could cause the helper invocation to fail on contexts lacking a GUI environment. For instance, when called from the task scheduler, a web server, or any other program not started inside an user session.

Hm. Given that you aren't spawning the program, none of the usual tricks to prevent the window popping will work.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^5: Private temporal files on Windows

Replies are listed 'Best First'.
Re^6: Private temporal files on Windows
by salva (Canon) on Dec 20, 2014 at 09:12 UTC
    But what really bothers is not the windows popping but if it will always be able to pop...

      If you have to go the private file route, this may help. It creates a file that can only be read by the current userid, and writes the password to it. It then waits for keyboard input and deletes the file.

      I've verified that other users, including administrators cannot read or delete the file, nor even inspect its permissions.

      Also, in theory, by using FILE_ATTRIBUTE_TEMPORARY, the contents may never actually be written to the disk, and (assuming a small file and a system file cache that is not overrun) only ever exist in cache. (In theory!)

      #include <windows.h> #include <sddl.h> #include <stdio.h> #include <conio.h> #include <Lmcons.h> #include "debug.h" #define TESTFILENAME "PermissionsTest.txt" int main( int argc, char **argv ) { char userName[ UNLEN+1 ]; char sid[ 400 ]; char *stringSID; char domainName[ 256 ]; SID_NAME_USE sidType; char pswd[] = "The quick brown fox"; char ssdTemplate[] = "O:%sD:P(A;;FA;;;%s)"; char ssd[1024]; SECURITY_DESCRIPTOR *psd = NULL; SECURITY_ATTRIBUTES sa = { sizeof( SECURITY_ATTRIBUTES ), NULL, 0 +}; ULONG sdSize, unSize = sizeof( userName ), sidSize = sizeof( sid ) +, dnSize = sizeof( domainName ), written; HANDLE h; DIEIF( !GetUserName( userName, &unSize ), NULL ); DIEIF( !LookupAccountName( NULL, userName, sid, &sidSize, domainNa +me, &dnSize, &sidType ), NULL ); printf( "Got sid\n" ); DIEIF( !ConvertSidToStringSid( sid, &stringSID ), NULL ); printf( "SID (as string): '%s'\n", stringSID ); sprintf_s( ssd, sizeof(ssd), ssdTemplate, stringSID, stringSID ); printf( "SSD: '%s'\n", ssd ); DIEIF( !ConvertStringSecurityDescriptorToSecurityDescriptor( ssd, +SDDL_REVISION_1, &psd, &sdSize ), NULL ); printf( "psd:%x sdSize: %d\n", psd, sdSize ); sa.lpSecurityDescriptor = psd; DIEIF( ( h = CreateFile( TESTFILENAME, GENERIC_WRITE, FILE_SHARE_READ, &sa, CREATE_ +ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL )) == INVALID_HANDLE_VALUE, NULL ); printf("File created\n" ); DIEIF( !WriteFile( h, pswd, sizeof( pswd ), &written, NULL ), NULL + ); printf( "File written '%s'\n", pswd ); while( !_kbhit() ) Sleep( 1 ); printf( "Closing file\n" ); DIEIF( !CloseHandle( h ), NULL ); DIEIF( !DeleteFile( TESTFILENAME ), NULL ); return 0; }

      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1110847]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-19 01:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found