Wednesday, January 5, 2011

Why Apple will never be an enterprise player.

Apple is kind of like the rich kid in high school who was an asshole, but everyone liked him because he had money.  I try to like Apple and their products, but the more I get to know them, the less I like them.  Besides the censorship and their situation with Adobe on their mobile devices, anytime I have to deal with their "enterprise technology" I am disappointed at the little things that break.  Yesterday was one of those days....

I have had an issue for several months now where when a PC connects to an SMB share on my OSX 10.6 server, it behaves strangely.  I can upload any file I want of any size I want to the Apple server, but when I try to pull the file down it errors out saying, "file is no longer accessible."  Another weird part is it gets extremely close to being done before it fails.  (For example, with a 6G file, it was within 20mb of completing, and with a 28k file, it copied more than 26k of it.)

I spent many, many hours Googling for a solution over the span of 6 months.  (Using USB drives for the rare occasion that files had to be transferred... and used sneaker-net to move them.)  Most of the solutions I found on forums blamed the PC and FAT file systems... you could tell they were written by mac-fanboys who don't have any idea about what they are talking about.  But enough about that rant, let me give you the answer.

It turns out that Samba was the problem.  So after reading about how the version of SMB that is distributed with OSX is way old, I started investigating how to up grade Samba to the latest edition (oh, btw, you use MACPORTS for that).  While I was waiting for the 8.9G of Apple developer tools to install so I could install MACPORTS, I by chance found another article or two:
http://discussions.apple.com/message.jspa?messageID=10532382
http://support.apple.com/kb/TS3179


ARE YOU FUCKING KIDDING ME APPLE?!?  You (YET AGAIN) release an update to something for your "enterprise-level" applications and FORGET TO TEST IT WITH SOMETHING AS SIMPLE AS SAMBA?  Not only that, but YOU CAN'T WRITE A DAMN SCRIPT TO FIX THE PROBLEM WHEN YOU FIND IT?

So it turns out that Samba shares "all" of the file, including the "Extended Attributes" that are specific to the XSAN file system.  Windows gets the file from the server, then when it receives the EA part it doesn't know what to do with them (as EA is not a Windows kind of thing) and discards the file with an error.  I made the change described in the KB article above and everything works fine now. (the solution is to change "stream support = yes" to "stream support = no" in /etc/smb.conf) .

So... I hope this post finds someone someday who might have the same problem that I did and may come across this post that might perhaps save a bit of their sanity.

Thanks internet for letting me rant.....

--

And now for some terms that I used to try to find this problem that may help this article be found by someone in need:

XSAN
the item can't be found
file disappear after copy
SMB mac
samba mac
OSX
XSERVE
mac windows compatibility
stream support = no
extended attributes
xsan and samba
xsan and smb
file copy to pc almost completes
file copy from xserve almost completes
Apple file sharing problem
apple file sharing issue
file size issue with SMB
file size issue with samba
smb connection issue
samba connection issue
windows osx samba
windows pull file from xsan
Problem connecting to my Windows (SMB) share in 10.6

Tuesday, December 21, 2010

Macs, Windows 7, and SMB shares

I was recently creating a SMB share on one of my Mac 10.6 servers that acted funny.  It would keep asking me to log in, even though I had the correct credentials.  I accidentally discovered that a Windows 2008 R1 machine could hit it just fine... but my Windows 7 box could not.  This lead to a search of the internets, and I discovered a somewhat-related problem (it was actually crashing Samba on the server side)...  Someone on that blog wrote that it has to do with NTLM.  I figure the security permissions were changed from Windows 2008 R1 to R2, and also between Vista and Windows 7.  The post mentions to change a bunch of stuff in the "local security policy" of the Windows box to make it work.  I don't like changing a whole lot of security stuff, especially loosing it... so here is all I changed to make this work , citing "nikonz" from the site above for the original fix (with my changes):

"Control Panel --> Administrative Tools --> Local Security Policy

Local Policies --> Security Options

Network security: LAN Manager authentication level
Send LM & NTLM responses - use NTLMv2 session security if negotiated"

There, once again my Macs and PCs are at peace with each other again.

Wednesday, December 8, 2010

3 hours = worlds longest command line

This was on one line, thought I would share it with everyone:

msdeploy -verb:sync -source:"metakey=lm/w3svc/571459,computername=server1" -dest:"metakey=lm/w3svc/2989,computername=server2" -skip:"objectName=metaProperty,attributes.name=LogFileDirectory" -skip:"objectName=metaProperty,attributes.name=SSLStoreName" -skip:"objectName=metaProperty,attributes.name=SSLCertHash" -skip:"objectName=metaProperty,attributes.name=SSLStoreName" -skip:"objectName=metaProperty,attributes.name=ServerBindings" -skip:"objectName=metaKey,attributes.path=blahTOBlah" -skip:"objectName=metaKey,attributes.path=HTTPtoHTPPS" -skip:"objectName=metaKey,attributes.path=redirectToBLAH" -skip:"objectName=metaProperty,attributes.name=AppFriendlyName" -skip:"objectName=metaProperty,attributes.name=SecureBindings" -skip:skipAction=delete -replace:"objectName=metaProperty,match=m:\websitelocation1,replace=x:\websitelocation1" -replace:"objectName=metaProperty,targetAttributeName=value,match=apppool2\.0,replace=apppool" -replace:"objectName=dirPath,match=m:\website1,replace=x:\website" -enableLink:AppPool -disableLink:ContentExtension -whatif > msdeploysync.log



Ouch.
--Bryan

Tuesday, December 7, 2010

Microsoft finally follows it's own RFC... now stuff is broken.

We have a web service that goes out and talks to other web services. Our web service and the other ones are protected by firewalls, as we don't want just anyone hitting our web services. As we move to windows 2008 r2, we noticed something funny was happening..... our connections were being blocked.
Turns out that Microsoft is finally following their own RFC and it is breaking things.  Windows servers now will use the "IP address most closely matching the gateway" to decide what IP address to use as the default one.  So now our webservice was using the "lowest" ip address we had, which was for a site that had nothing to do with the webservice.
I found out I wasn't alone being surprised by this new "feature" and found that there is a workaround.
In short, you need to:
-Download and apply the hofix. (the MS extractor was currupt, so I used 7zip to extract the files)
-Reboot for the hotfix to take effect.
-Gather a list of all your IP addresses on that machine, take out the one you want to be the "default IP." Put them in the variable $currentIPs.  Then you can run the script as below, it will remove and add the IPs all at once with little downtime.

I forgot to remote desktop using the FQDN, so I was disconnected, but when I reconnected everything was happy.


$currentIps = "10.1.1.1","10.1.1.2","10.1.1.3","10.1.1.4"


foreach ($ip in $currentIps){

netsh interface ip delete address public $ip
write-host "$ip deleted"
netsh interface ip add address "public" $ip 255.255.255.0 skipassource=true
write-host "$ip added"
}
Write-Host "I suggest you reboot your server now, just in case."


Notice the "skipassource=true."  This will not work before the hotfix.  Again you do not want to run that parameter with your IP address that you DO want to be the default one.
(My Subnet mask is 255.255.255.0, if yours is different, then change it above.)

Monday, November 29, 2010

Windows Auditing can be annoying. (Shut up already)

My audit logs were filling up with a bunch of B.S. from perfectly good packets being successfully sent and received. (event id 5157, and 5152) By default, Windows thinks you want all of these packets logged... and perhaps some admins do. But they can be logged in the firewall log, I don't want them in the event log too. (Default location of the Windows Firewall log is at "C:\Windows\system32\LogFiles\Firewall\pfirewall.log") So after a bunch of googleing, I found several answers that almost worked. Here is what really worked for me on Windows 2008 R2 and R1:


auditpol /set /subcategory:"Filtering Platform Packet Drop" /success:disable /failure:disable

auditpol /set /subcategory:"Filtering Platform Connection" /success:disable /failure:disable

So there you go, save some audit log space for something that matters, like non-firewall stuff.
-Bryan

(oh, and one more thing, if you want to create a Group policy for this, it is under
computer configuration --> policies --> windows settings --> security settings --> advanced audit policy configuration --> audit policies --> object access. Then double click "Audit Filtering Platform Connection" and check only the box next to "configure the following audit events." DO NOT CLICK THE OTHER TWO BOXES. Repeat for "Audit Filtering Platform Packet Drop" too. If this does not work, edit your GPO to include the policy outlined in Method 1, steps 2 and 3 from http://support.microsoft.com/kb/921468 .  REMEMBER, THE GPO MIGHT TAKE SOME TIME, so if you don't reboot, give it at least 90 min before you give up on the GPO idea.)

Monday, October 11, 2010

Social Engineering, be careful what you ask for.

After planning on the trip to Vegas involving a unique idea with friends, I learned some things: (vagueness is purposeful as to not give too much away, this was in Vegas after all)
1) sometimes people will inherently trust or hate you based upon only what you are wearing.
2) Everyone likes to hang around with someone who is having a good time that is considered someone who shouldn't/can't.
3) Combined with #1, if you listen, people will speak to you.
4) Sometimes people just need to speak about their problems, even if the foundation of their trust is a lie. See #1. No matter what the trust is based on, it will still make them feel better.
5) By hearing other people's problems, it will probably make your problems seem smaller in comparison.
6) Everyone loves a man in a uniform.
7) Sometimes the best person to convince others to become religious is an atheist.
8) Margarita salt is not crack rock, no matter what crazy ladies tell you on the street corner.
9) No one wants to hit a father, or hit on, or be hit on by.
10) Everyone is curious about Buddhism, so will believe anything.... even if it is nothing.
11) If you are going to wear it, go all the way.
12) Lesbians are ok with men of the cloth, as long as they stay that way. But their friends might be ok with some change.
13) Photo bombing is not a sin if you are the judge of sin.
14) Hooters waitresses are usually nice girls who just need a job.
15) A priest who is having trouble walking is more convincing than a priest with communion wine bottle on his own two feet.
16) Motorcycles are still awesome.

Thursday, September 30, 2010

Install IIS and other IIS stuff on Server or a Desktop

I searched around, and didn't find anyone who had a way to install IIS from POSH. And if they got close, they didn't say that it didnt work on a server, or a desktop depending on the script. So here is one that will work on both, depending on what the user says they have:
#########################################################
#
# Script to install IIS.
#
# Created Sept 20, 2010
# Bryan Loveless 
#
#
# Requires Powershell 2.0
#
# Change your Execution policy to RemoteSigned if running locally
# by: Set-executionpolicy -executionpolicy RemoteSigned
#
#Prereqs: 
#
########################################################


$whorunsthis = Read-host "Is this a (S)erver or your (L)ocal_Developer box? (S/L)"

if ($whorunsthis -eq "S" )
    {   
 #get-windowsfeature will get list of Windows Component Intalled on SERVER

 Import-Module servermanager

 add-windowsfeature Application-Server
 add-windowsfeature AS-NET-Framework
 add-windowsfeature AS-Web-Support 
 add-windowsfeature AS-WAS-Support
 add-windowsfeature AS-HTTP-Activation  
 add-windowsfeature File-Services
 add-windowsfeature FS-FileServer
 add-windowsfeature Web-Server
 add-windowsfeature Web-WebServer
 add-windowsfeature Web-Common-Http
 add-windowsfeature Web-Static-Content
 add-windowsfeature Web-Default-Doc
 add-windowsfeature Web-Dir-Browsing
 add-windowsfeature Web-Http-Errors
 add-windowsfeature Web-Http-Redirect
 add-windowsfeature Web-App-Dev
 add-windowsfeature Web-Asp-Net
 add-windowsfeature Web-Net-Ext
 add-windowsfeature Web-ISAPI-Ext
 add-windowsfeature Web-ISAPI-Filter
 add-windowsfeature Web-Health
 add-windowsfeature Web-Http-Logging
 add-windowsfeature Web-Log-Libraries
 add-windowsfeature Web-Request-Monitor
 add-windowsfeature Web-Http-Tracing
 add-windowsfeature Web-Security
 add-windowsfeature Web-Basic-Auth
 add-windowsfeature Web-Windows-Auth
 add-windowsfeature Web-Digest-Auth
 add-windowsfeature Web-Client-Auth
 add-windowsfeature Web-Cert-Auth
 add-windowsfeature Web-Url-Auth
 add-windowsfeature Web-Filtering
 add-windowsfeature Web-IP-Security
 add-windowsfeature Web-Performance
 add-windowsfeature Web-Stat-Compression
 add-windowsfeature Web-Dyn-Compression
 add-windowsfeature Web-Mgmt-Tools
 add-windowsfeature Web-Mgmt-Console
 add-windowsfeature Web-Scripting-Tools
 add-windowsfeature Web-Mgmt-Service
 add-windowsfeature NET-Framework
 add-windowsfeature NET-Framework-Core
 add-windowsfeature NET-Win-CFAC
 add-windowsfeature NET-HTTP-Activation
 add-windowsfeature Multipath-IO
 add-windowsfeature RSAT
 add-windowsfeature RSAT-Role-Tools
 add-windowsfeature RSAT-Web-Server       
 add-windowsfeature SNMP-Services
 add-windowsfeature SNMP-Service
 add-windowsfeature SNMP-WMI-Provider
 add-windowsfeature Windows-Internal-DB
 add-windowsfeature PowerShell-ISE
 add-windowsfeature WAS
 add-windowsfeature WAS-Process-Model
 add-windowsfeature WAS-NET-Environment
 add-windowsfeature WAS-Config-APIs
 add-windowsfeature WSRM

}

elseif ($whorunsthis -eq "L")
    { 

 #oclist will give a list of what is possible
 # or try http://technet.microsoft.com/en-us/library/cc722041%28WS.10%29.aspx

 #below is for Desktops (windows 7)

 # install IIS Role
 ocsetup IIS-WebServerRole
 ocsetup IIS-WebServer
 ocsetup IIS-CommonHttpFeatures
 ocsetup IIS-DefaultDocument
 ocsetup IIS-HttpErrors
 ocsetup IIS-HttpRedirect
 ocsetup IIS-StaticContent
 ocsetup IIS-HealthAndDiagnostics
 ocsetup IIS-CustomLogging
 ocsetup IIS-HttpLogging
 ocsetup IIS-LoggingLibraries
   #ocsetup MSMQ-HTTP possbily needed for Ektron
 ocsetup IIS-RequestMonitor
 ocsetup IIS-Performance
 ocsetup IIS-HttpCompressionDynamic
 ocsetup IIS-HttpCompressionStatic
 ocsetup IIS-Security
 ocsetup IIS-BasicAuthentication
 ocsetup IIS-ClientCertificateMappingAuthentication
 ocsetup IIS-IISCertificateMappingAuthentication
 ocsetup IIS-IPSecurity
 ocsetup IIS-RequestFiltering
 ocsetup IIS-WindowsAuthentication
 ocsetup IIS-WebServerManagementTools
 ocsetup IIS-IIS6ManagementCompatibility
 ocsetup IIS-ManagementConsole

 # install .net
 ocsetup NetFx2-ServerCore
 ocsetup NetFx2-ServerCore-WOW64
 ocsetup NetFx3
 
 #install ASP
 ocsetup IIS-ASP
 
 # install asp.net  start /w
 ocsetup WAS-NetFxEnvironment
 ocsetup IIS-ISAPIExtensions
 ocsetup IIS-ISAPIFilter
 ocsetup IIS-NetFxExtensibility
 ocsetup IIS-ASPNET
 ocsetup IIS-ApplicationDevelopment
 ocsetup WCF-HTTP-Activation

}

else
    {write-host "you must select S or L"  
    Exit}