April 2016 Archives

Wed Apr 27 12:15:42 ICT 2016

Find what package installed a file.

To find what package installed a given file, use the command:

pkg which filename

Posted by Olivier | Permanent link | File under: administration, freebsd, ports

Wed Apr 27 11:51:29 ICT 2016

Upgrading Berkeley DB

Berkeley DB is used as a backend for LDAP at CSIM. To upgrade it:

  1. Stop LDAP;
  2. Goto /var/db/openldap-data;
  3. db_checkpoint-old.version -l to create a checkpoint;
  4. db_recover-old.version to make sure the files are in a stable state;
  5. db_recover-new.version -e to migrate the files to the new version;
  6. Start LDAP.

Posted by Olivier | Permanent link | File under: administration, freebsd

Wed Apr 27 10:17:00 ICT 2016

Make small images for Magic Thumb in Joomla

On ufo go to the directory where the images reside and run reduce.pl.

It works in GIF images only for for an images image.gif it creates the reduced image image-s.gif which is 200 pixels wide.

It also prints the code that should be used for that image:

<!--
<a class="MagicThumb" href="../laboratory/printer/ricoh.gif">
<img src="../laboratory/printer/ricoh-s.gif" alt="" width="200"
height="185" hspace="5"/></a>
-->

Posted by Olivier | Permanent link | File under: administration, web

Wed Apr 27 09:57:32 ICT 2016

Using find to delete old files recursively

find . -mtime +21d -depth -delete

To delete files and directories with a modification date older than 21 days.

-depth is needed to ensure a in-depth tree recursion, so the directories can be deleted only after they have been emptied.


Posted by Olivier | Permanent link | File under: administration, freebsd

Tue Apr 26 14:26:07 ICT 2016

Adding a printer to Samba

Add the new printer to Samba configuration

Edit the Samba configuration file smb.conf (usually located in /usr/local/etc/smb.conf) to add the new printer:

[sec PCL]
        comment = HP2200dn PCL in #123
        printer name = sec
        path = /tmp
        printable = Yes
        use client driver = No
        printer admin = on, sanjeet, adul, root
        default devmode = No

Upload the driver to Samba

The following works for Samba 3 and Windows XP only.

On a Windows XP machine, connect with and account that has Samba administrator privileges, in CSIM it should be "User Name: root" "Domain: SAMBA". Open Windows Explorer and go to the directory Printers and Faxes of the Samba server: \\banyan\Printers and Faxes

Right click on the background of Windows Explorer window and choose Server Properties from the contextual menu.

Select the tab Drivers and proceed to add a new drivers on the Samba server.

You will see that the files of the new driver are copied to \\banyan\print$\M32X86

On the Samba server, you can check that new files have been added to the directory defined in the path of the share print$. For Windows XP, the files are added in the subdirectory M32X86.

On the Samba server you can use the following command to get the list of installed drivers:

# rpcclient -U'root%******' -c 'enumdrivers' banyan

[Windows NT x86]
Printer Driver Info 1:
        Driver Name: [HP LaserJet P4010_P4510 Series PCL 6]

Printer Driver Info 1:
        Driver Name: [HP LaserJet 4300 PS]

Printer Driver Info 1:
        Driver Name: [HP LaserJet 4300 PCL 6]

Printer Driver Info 1:
        Driver Name: [HP Universal Printing PS]

#
Assign a driver to the new printer

On the Samba server, use the following command to assign one driver to one printer:

# rpcclient -U'root%*****' -c 'setdriver sec\ PCL HP\ LaserJet\ 4300\ PCL\ 6' banyan
Successfully set sec PCL  to driver HP LaserJet 4300 PCL 6.
#

Note that if the name of the printer of the name of the driver contains any space, they are escaped with \.

To see if a driver has been configured, use the command:

# rpcclient -U'root%*****' -c 'getdriver sec\ PCL' banyan
[...]
#

It lists all the files corresponding to the driver or returns an error message.

Configure the driver for the printer

On a Windows XP machine, connect with Samba administrator account, in CSIM it should be "User Name: root" "Domain: SAMBA". Open Windows Explorer and go to the directory Printers and Faxes of the samba server:\\banyan\Printers and Faxes

Right click on the name of the printer and select "Properties".

Configure the tab "Device Settings" and "Advanced/Printing Defaults".

Add the pinter to the Windows clients

Use Add Printer Wizard.


Posted by Olivier | Permanent link | File under: administration, samba, ms_windows

Tue Apr 26 13:47:46 ICT 2016

Preparing Windows 7 to join Samba 3

A Windows 7 workstation cannot join a domain controled by Samba 3 without some initial preparation work. The following relaxes some of the security features introduced in Windows 7.
  1. Edit the group policy: In Computer/Windows Settings/Security Settings/Local Policies/Security Options:
    • set Network Security: LAN Manager Auth. Level to Send LM&NTLM use NTLMv2 session sec. if negociated;
    • unchek Required 128b encryption for both Network Security: Minimum session... clients and server.
  2. Open the registry editor and modify the following (or save the following code in a .reg file and double-click it):
    Windows Registry Editor Version 5.00
    
    ; Win7/Samba 3.4.x - Workstation Share
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\lanmanserver\parameters]
    "AutoShareWks"=dword:00000001
    
    ; Win7/Samba 3.4.x - Compat
    [HKEY_LOCAL_MACHINE\System\CurrentControlSet\services\lanmanworkstation\parameters]
    "DNSNameResolutionRequired"=dword:00000000
    "DomainCompatibilityMode"=dword:00000001
    ; AllowPlain ....
    ; RequireSecuritySignature"=dword:00000000
    
    ; Win7/Samba 3.4.x - Compat
    ; http://us.generation-nt.com/answer/samba-rejecting-auth-request-client-xxx-machine-account-win7-help-206090182.html#206092242
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\netlogon\parameters]
    "DisablePasswordChange"=dword:00000001
    "RequireSignOrSeal"=dword:00000001
    "RequireStrongKey"=dword:00000001
    
    ;Turn off last user logged in stuff.
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system]
    "dontdisplaylastusername"=dword:00000001
    
    ;Disable the security center stuff annoyances
    ; [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\wscsvc]
    ; "Start"=dword:00000003
    
    ; Speedup settings
    [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System]
    "SlowLinkDetectEnabled"=dword:00000000
    "DeleteRoamingCache"=dword:00000001
    "WaitForNetwork"=dword:00000000
    "CompatibleRUPSecurity"=dword:00000001
    
    ; Can drive you nuts
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
    "EnableLUA"=dword:00000000
    "LocalAccountTokenFilterPolicy"=dword:00000001
    
    ;Stupid keys that make the windows 7 sysprep crap out.
    [HKEY_LOCAL_MACHINE\SYSTEM\Setup]
    "RestartSetup"=dword:00000000
    "SetupType"=dword:00000000
    "SystemSetupInProgress"=dword:00000000
    "SetupPhase"=dword:00000000
    "CmdLine"=""
    "OOBEInProgress"=dword:00000000
    

Posted by Olivier | Permanent link | File under: administration, samba, ms_windows