<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Don't use global state to manage a local problem</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2008/12/11/9193695.aspx</link><description>Reiteration of a guiding principle.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Don't use global state to manage a local problem</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2008/12/11/9193695.aspx#9224218</link><pubDate>Tue, 16 Dec 2008 09:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9224218</guid><dc:creator>Anonymous Coward</dc:creator><description>&lt;p&gt;@SuperKoko: your post is too incoherent to be really sure, but I think I have already answered most of your questions in previous posts.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9224218" width="1" height="1"&gt;</description></item><item><title>re: Don't use global state to manage a local problem</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2008/12/11/9193695.aspx#9222712</link><pubDate>Tue, 16 Dec 2008 02:17:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9222712</guid><dc:creator>SuperKoko</dc:creator><description>&lt;p&gt;&amp;gt; @Mark yourself as an administrative tool, then you&lt;/p&gt;
&lt;p&gt;&amp;gt; will have permission to change the time.: I didn't&lt;/p&gt;
&lt;p&gt;&amp;gt; say that and I wouldn't be in favour of that.&lt;/p&gt;
&lt;p&gt;So, how do you let the third-party administrative tool X which does modify a system setting for a good reason, do it.&lt;/p&gt;
&lt;p&gt;Somehow, it has to declare it, which you don't wish, or the user has to get a pop-up.&lt;/p&gt;
&lt;p&gt;&amp;quot;Frankly I don't get what people hate about UAC.&amp;quot;&lt;/p&gt;
&lt;p&gt;UAC is russian roulette.&lt;/p&gt;
&lt;p&gt;Assuming there are two kinds of applications:&lt;/p&gt;
&lt;p&gt;1) Normal trustable applications. Sometimes, they need high privileges to do their tasks.&lt;/p&gt;
&lt;p&gt;e.g. Network clock synchronization requires privileges to set the clock.&lt;/p&gt;
&lt;p&gt;Or, a network tool to change the time zone on a whole LAN at a time, require privileges to set the time zone.&lt;/p&gt;
&lt;p&gt;2) Worms, malwares, viri...&lt;/p&gt;
&lt;p&gt;For applications of kind #1, the &amp;quot;right&amp;quot; answer to UAC is always YES. Clicking NO will (almost) always result in malfunction of the software.&lt;/p&gt;
&lt;p&gt;For applications of kind #2, the &amp;quot;right&amp;quot; answer is always NO. This might not always totally stop the malware, but, clicking YES will only makes things worse.&lt;/p&gt;
&lt;p&gt;In BOTH cases, a message box convincing the user to click YES can trivially be written. I would even say that it's easier for malwares as they are &amp;quot;free&amp;quot; to tell lie.&lt;/p&gt;
&lt;p&gt;So, the message box can be ignore, and the UAC question always comes down to:&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;Hi, I'm Windows. I'm going to do perform dangerous operation, but I don't know if the program asking for it is evil or not, so, could you tell me:&lt;/p&gt;
&lt;p&gt;Are you executing a malware?&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;When computers have no clue what they're doing, desperate, they ask the user.&lt;/p&gt;
&lt;p&gt;(I don't know details, but UAC might also be a problem when managing hundred computers on a LAN and not wanting to click YES hundred times).&lt;/p&gt;
&lt;p&gt;Now, we see that there's a third kind of application.&lt;/p&gt;
&lt;p&gt;3) Trusted non-malware applications, badly programmed, which modify a global setting to perform an internal calculation.&lt;/p&gt;
&lt;p&gt;However, the answer to the UAC should be YES there too, as the application won't work at all if NO is answered, and, surely, the user wants the application to work. So, from a security &amp;amp; user point-of-view kind #3 and kind #1 are the same.&lt;/p&gt;
&lt;p&gt;If the declarative model is used, applications of kind #1 and #3 will properly declare that they need these privileges, while, worms will be blocked unless they manage to execute with &amp;quot;installer&amp;quot; privileges (the privileges needed to declare privileges of applications).&lt;/p&gt;
&lt;p&gt;This model doesn't help bad developers to fix applications of kind #3.&lt;/p&gt;
&lt;p&gt;If the &amp;quot;pop-up&amp;quot; model is used, applications of kind #1 will pop out dialog boxes as part of their normal behavior, and that won't be a bug.&lt;/p&gt;
&lt;p&gt;Applications of kind #3 will do the same, and these &amp;quot;pop-ups&amp;quot; won't be reported as bugs during testing.&lt;/p&gt;
&lt;p&gt;This model doesn't help bad developers to fix applications of kind #3.&lt;/p&gt;
&lt;p&gt;However, this model helps worms to propagate, compared to the other model.&lt;/p&gt;
&lt;p&gt;Proper education of *developers* is the only way to fix applications of kind #3.&lt;/p&gt;
&lt;p&gt;&amp;quot;There could be other ways to pass to handles to programs&amp;quot;&lt;/p&gt;
&lt;p&gt;Which one?&lt;/p&gt;
&lt;p&gt;&amp;quot;A common dialog could do the same kind of thing.&amp;quot;&lt;/p&gt;
&lt;p&gt;ok.&lt;/p&gt;
&lt;p&gt;So, a network clock synchronization tool would've to pop up the system clock? Looks weird to me.&lt;/p&gt;
&lt;p&gt;What dialog would you show when modifying some obscure registry setting such as obcaseinsensitive, or the user profile folder path?&lt;/p&gt;
&lt;p&gt;Would the admin have to close this dialog box on the hundred computers of his LAN?&lt;/p&gt;
&lt;p&gt;Give a concrete proposal, with an API and a description of some applications, and I'll read it, but you're being vague enough to make it hard to understand what you're thinking.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9222712" width="1" height="1"&gt;</description></item><item><title>re: Don't use global state to manage a local problem</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2008/12/11/9193695.aspx#9221938</link><pubDate>Mon, 15 Dec 2008 21:53:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9221938</guid><dc:creator>Giuseppe</dc:creator><description>&lt;p&gt;(back to the topic?)&lt;/p&gt;
&lt;p&gt;Sometimes it is difficult for the developer to follow the rule. I have seen many (most of) compression/archieving tools that become &amp;quot;the&amp;quot; global compression/archieving tool (and when one tries to uninstall them, the registry is often messed up, and the native &amp;quot;compressed folder&amp;quot; feature is lost; but this is a bug, of course). The problem is that their GUI are very different. I actually don't know if registering the new application is &amp;nbsp;always a good thing. In my little experience, it is often a source of problems. But I also understand the &amp;quot;marketing&amp;quot;: if you sell a &amp;quot;good archiver&amp;quot;, you &amp;quot;want&amp;quot; to throw the native one away, right?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9221938" width="1" height="1"&gt;</description></item><item><title>re: Don't use global state to manage a local problem</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2008/12/11/9193695.aspx#9221821</link><pubDate>Mon, 15 Dec 2008 21:29:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9221821</guid><dc:creator>Anonymous Coward</dc:creator><description>&lt;p&gt;@Mark yourself as an administrative tool, then you will have permission to change the time.: I didn't say that and I wouldn't be in favour of that.&lt;/p&gt;
&lt;p&gt;@Thread injection: that opens up a whole 'nother can o' worms, but I think that would take this thread too far off topic.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9221821" width="1" height="1"&gt;</description></item><item><title>re: Don't use global state to manage a local problem</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2008/12/11/9193695.aspx#9221745</link><pubDate>Mon, 15 Dec 2008 21:12:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9221745</guid><dc:creator>Yuhong Bao</dc:creator><description>&lt;p&gt;[I read it but I don't post to it because I post here. And thanks for taking this thread even further off topic. -Raymond]&lt;/p&gt;
&lt;p&gt;Thanks for confirming, because it is hard to tell if you don't post there.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9221745" width="1" height="1"&gt;</description></item><item><title>re: Don't use global state to manage a local problem</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2008/12/11/9193695.aspx#9221649</link><pubDate>Mon, 15 Dec 2008 20:53:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9221649</guid><dc:creator>Yuhong Bao</dc:creator><description>&lt;P&gt;"Example deleted because it violates the ground rules against identifying a specific company, program, or person. This commenter, despite his/her enthusiasm, tends to violate the ground rules and eventually I will tire of editing the comments and start deleting them."&lt;/P&gt;
&lt;P&gt;Well, good thing that there is off-roading the old new thing. BTW, it don't seem to be very active. Raymond: Do you read off-road? Because you don't seem to post in it.&lt;/P&gt;
&lt;DIV class=post&gt;[&lt;I&gt;I read it but I don't post to it because I post here. And thanks for taking this thread even further off topic. -Raymond&lt;/I&gt;]&lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9221649" width="1" height="1"&gt;</description></item><item><title>re: Don't use global state to manage a local problem</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2008/12/11/9193695.aspx#9220218</link><pubDate>Mon, 15 Dec 2008 14:41:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9220218</guid><dc:creator>Anonymous Coward</dc:creator><description>&lt;P&gt;@Broken applications are broken. Only their developers, or Windows hacks as we see on The old new thing, can fix them.: True, but if broken means that your application doesn't even work in testing, hopefully devs will have some incentive to fix a bug before shipping.&lt;/P&gt;
&lt;P&gt;@getting pop-ups they don't understand: Then make them get pop-ups they do understand. Frankly I don't get what people hate about UAC. The only thing I kind of don't like is how the pop up is too generic. The most central item in a good dialog would be what the application is actually trying to do.&lt;/P&gt;
&lt;P&gt;(And to add to the above two paragraphs: there are lots of things for which it doesn't make sense to be able to ask the operating system for a privilege. The time zone only needs to be set by the time date applet, which is started by the shell, which will pass the handle on because it knows it's starting the time date applet, or computer setup programs and administration tools, to which you could pass the handle on startup similarly to how we pass command line parameters now. Regardless, either you can change the time zone, or you can't. No way to ask = no pop up.)&lt;/P&gt;
&lt;DIV class=post&gt;[&lt;I&gt;Q: "I need to change the time programmatically in order to perform this internal computation." A: "Mark yourself as an administrative tool, then you will have permission to change the time." Now you're back where you started. Or worse, A: "Inject a thread into Explorer to change the time." Now you have a problem worse than the original problem. -Raymond&lt;/I&gt;]&lt;/DIV&gt;
&lt;P&gt;@Anyway, ... tables".: Logical fallacy: false dichotomy. There could be other ways to pass to handles to programs, and if you design the system right, I think that you could get most applications working just right without requiring the user or shell to do anything specific. For example, if you open a document from an Explorer window, Explorer could pass a handle to that document to the application it starts, much like we pass filenames today. A common dialog could do the same kind of thing.&lt;/P&gt;
&lt;P&gt;Pure per-application instead of per process has a major deficiency, in that it would be hard to give different instances different access (which you might want sometimes) and to pass handles to running processes. It could be done, but it would be harder and less intuitive.&lt;/P&gt;
&lt;P&gt;Backward compatibility could be done using an emulation layer. It would for example interpret a CreateFile( &amp;lt;path&amp;gt; ) as ‘look if there's a handle open in this process that corresponds to path’. It can be done, and it probably wouldn't even be that difficult. You could even pass a handle to a folder to make all files in it accessible.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9220218" width="1" height="1"&gt;</description></item><item><title>re: Don't use global state to manage a local problem</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2008/12/11/9193695.aspx#9219647</link><pubDate>Mon, 15 Dec 2008 12:58:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9219647</guid><dc:creator>SuperKoko</dc:creator><description>&lt;p&gt;@Anonymous Coward:&lt;/p&gt;
&lt;p&gt;A per-application (application being defined by an exe path name + SHA1) access control model would be nice. That would be a generalization of network firewalls to system calls &amp;amp; all other privileges.&lt;/p&gt;
&lt;p&gt;However it wouldn't solve the issue of trusted applications changing the global state as part of their internal calculation:&lt;/p&gt;
&lt;p&gt;Either applications, when installed, declare the privileges they need, in which case, the application would declare that it sets the time zone, or the user would have to configure that for every application, getting pop-ups they don't understand as UAC does. Even if they manage to understand the pop-up, they'll first click &amp;quot;No&amp;quot; and see that the application doesn't work, so they'll eventually give the privilege the application asks.&lt;/p&gt;
&lt;p&gt;Access control can protect against worms &amp;amp; trojans, but cannot automagically repair broken applications. Broken applications are broken. Only their developers, or Windows hacks as we see on The old new thing, can fix them.&lt;/p&gt;
&lt;p&gt;Anyway, I don't see how the handle model can be used to implement per-application access control. Either the explorer would pass all the handles to every child process it invokes or it would use an application table to select which handles it must passes to child processes. The latter would be very weak as there're many ways to launch applications without explorer, and every application allowing people to launch other applications would've to use these &amp;quot;firewall tables&amp;quot;.&lt;/p&gt;
&lt;p&gt;The per-application model used by network firewall is much better IMO.&lt;/p&gt;
&lt;p&gt;There's also the argument of backward compatibility. Handles based access control would significantly change the Windows API.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9219647" width="1" height="1"&gt;</description></item><item><title>re: Don't use global state to manage a local problem</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2008/12/11/9193695.aspx#9216317</link><pubDate>Mon, 15 Dec 2008 02:56:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9216317</guid><dc:creator>Anonymous Coward</dc:creator><description>&lt;p&gt;That is certainly true and it deserves more credit for that than it gets.&lt;/p&gt;
&lt;p&gt;However, the shell automatically passes the privilege on to the applications it spawns, which is bad. I want to be able to change the time zone, sure. But only the time and date applet should be able to do this on my behalf, so the shell should only pass the privilege on to that applet, and perhaps others that I explicitly specify.&lt;/p&gt;
&lt;p&gt;Also, the access control model is certainly a big improvement over POSIX, but it still leaves a lot to be desired, especially in terms of consistency and default configuration. Some things are controlled by privileges, as the time zone. Other things are controlled by passing handles around (or failing to do so). Yet other things are accessed by pathname which are then on access checked against ACLs which operate by user and group, not by application. &amp;nbsp;The default settings are almost all too permissive.&lt;/p&gt;
&lt;p&gt;I think the handle model is the easiest to work with and reason about, as well as the most flexible and the easiest to get watertight, so if we, theoretically speaking, were to adopt one of these models, I'd opt for that one. It also has the nice property that it would be easy (relatively speaking) to add the necessary infrastructure to make it emulate the other two if necessary.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9216317" width="1" height="1"&gt;</description></item><item><title>re: Don't use global state to manage a local problem</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2008/12/11/9193695.aspx#9214578</link><pubDate>Sun, 14 Dec 2008 22:15:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9214578</guid><dc:creator>Yuhong Bao</dc:creator><description>&lt;P&gt;Another example:&lt;/P&gt;
&lt;P&gt;&lt;FONT color=red&gt;Example deleted because it violates the ground rules against identifying a specific company, program, or person. This commenter, despite his/her enthusiasm, tends to violate the ground rules and eventually I will tire of editing the comments and start deleting them.&lt;/FONT&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9214578" width="1" height="1"&gt;</description></item></channel></rss>