Posts mit dem Label windows werden angezeigt. Alle Posts anzeigen
Posts mit dem Label windows werden angezeigt. Alle Posts anzeigen

Donnerstag, 25. Oktober 2018

Use PAM to mount network share in Ubuntu 18.04

In this example a user mount script will be created which will mount a Windows network share.

At first make sure you have the cifs package installed on your system:

bash$ sudo apt-get install cifs-utils

Then it is necessary to change the following lines in the PAM configuration file (underlined parts were changed).
/etc/security/pam_mount.conf.xml:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE pam_mount SYSTEM "pam_mount.conf.xml.dtd">
<!--
        See pam_mount.conf(5) for a description.
-->

<pam_mount>

                <!-- debug should come before everything else,
                since this file is still processed in a single pass
                from top-to-bottom -->

<debug enable="0" />

                <!-- Volume definitions -->


                <!-- pam_mount parameters: General tunables -->

<luserconf name=".pam_mount.conf.xml" />

<!-- Note that commenting out mntoptions will give you the defaults.
     You will need to explicitly initialize it with the empty string
     to reset the defaults to nothing. -->
<mntoptions allow="nosuid,nodev,loop,encryption,fsck,nonempty,allow_root,allow_other,credentials" />
<!--
<mntoptions deny="suid,dev" />
<mntoptions allow="*" />
<mntoptions deny="*" />
-->
<mntoptions require="nosuid,nodev" />

<!-- requires ofl from hxtools to be present -->
<logout wait="0" hup="no" term="no" kill="no" />


                <!-- pam_mount parameters: Volume-related -->

<mkmountpoint enable="1" remove="true" />


</pam_mount>
In luserconf the name of user PAM configuration file is specified. It is also necessary to add credentials as allowed mount option, so that it is possible to specify a file with user credentials.

The file in the user directory looks like this:

~/.pam_mount.conf.xml:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE pam_mount SYSTEM "pam_mount.conf.xml.dtd">

<pam_mount>
        <volume
        options="nodev,nosuid,credentials=/home/%(USER)/.smb.cred"
        user="*"
        mountpoint="<path to mount point>"
        path="<path to share>"
        server="<server name>"
        fstype="cifs" />
</pam_mount>

In the credentials file the user name, password and domain are set:

~/.smb.cred:
username=<username>
password=<password>
domain=<domain>

The obvious disadvantage of this method is, that the password will be stored in clear text on the system, unless the users home directory is encrypted. The password can be omitted though if it is the same for the user login and for mounting the network share. Probably this is also true for the user name.

The next step restricts the file access rights to a bare minimum, so that only the current user can read an write the files:

bash$ chmod 600 ~/.pam_mount.conf.xml ~/.smb.cred

If a problem occurs and the network share is not mounted debugging can be enabled in the PAM configuration file.

/etc/security/pam_mount.conf.xml:
<debug enable="1" />

The debug messages can then be found in /var/log/auth.log.

Freitag, 14. September 2018

Mount Windows network shares with Dolphin and Nautilus in Ubuntu

Make sure you have installed the cifs-utils and smbclient packages:
# apt-get install cifs-utils smbclient
After you have installed the packages try to access the Windows share with the smbclient tool:
$ smbclient -U <user name> -L //<server name>  -W <domain name>
 
If you get the following error message: protocol negotiation failed: NT_STATUS_INVALID_NETWORK_RESPONSE
try to specify a protocol version:
$ smbclient -U <user name> -L //<server name>  -W <domain name> -m <protocol version, e. g. SMB2>
In this case you need to create a configuration file with the following content:
~/.smb/smb.conf
[global]                                                                                                                                                                          
  workgroup = <domain name>                                                                                                                                                  
  client max protocol = <protocol version>

It should now be possible to access the shares with Nautilus and Dolphin. Use the following format to mount the network share:
  • Nautilus: smb://<domain name>,<user name>@<server name>/<share name>
  • Dolphin: smb://<domain name>\<user name>@<server name>/<share name>
 Another option would be to mount the network share:
$ sudo mount --types cifs --options uid=${USER},gid=100,user=<windows user name>,domain=<domain name> //<server name>/<share name> <mount path>
The directory where the share should be mounted must exist.

Dienstag, 14. November 2017

Windows firewall rule for Open DHCP Server

The Windows firewall will normally block requests to the DHCP server, so an exception has to be added to the firewall fules.
Open Windows Defender Firewall with Advanced Security and go to Inbound Rules.
In General tab make sure the rule is enabled and Action is Allow the connection. In Programs and Services select the Open DHCP Server executable. In Protocols and Ports select UDP as Protocol type and enter 67, 68, 547, 546 as Specific Ports.  In the Advanced tab make sure the rule is selected for the current profile.

Dienstag, 17. März 2015

Creating A Windows 7 SP1 USB Installer With Language Packs And Updates Integrated

Now that Windows 8.1 has been released for a while and Windows 10 is coming in the near future this information is probably a little dated but if you need to create a Windows 7 installer USB stick then hopefully this information will help you. You can only use the part you're interested, for example you might only be interested in integrating the updates and creating an installer ISO then you can simply skip the other parts. This guide is splitted into the following sections:
  • Needed tools
  • Integrating the language packs
  • Integrating the updates and creating the ISO
  • Creating a GPT formated USB stick

Needed Tools

  • Windows 7 ISO with SP1 integrated: You can get the English ISO here: Windows 7 SP1 ISO
  • 7-ZIP: Tool to extract files from downloaded ISO
  • Language pack you want to install:  Language packs (make sure you download the correct version: X86, X64)
  • exe2cab: Tool needed to convert language pack executables to cab files
  • DISM: I think this tool is included in Windows starting with Windows 7. If you don't have this tool installed you can try GetWaikTools to download it. This tool is needed to integrate the language packs.
  •  There are two options you can use to download the Windows Updates: You can either use a tool which uses updates list or use a tool which uses Windows Updates to check for the available updates. Each option does have it's own strength:
    • Tools which use updates list don't need a running version of your target Windows. Examples are:
    • Tools which use Windows Updates have the advantage that they use the same mechanism which Windows uses to determine the needed updates which means they will always list all updates which are currently available. The disadvantage is that you need to have a running version of your target Windows installation:
      • Portable Update: This tool will download the Windows updates as .cab files which seems to be faster to integrate then the .msu files downloaded by Windows Updates Downloader
  • optional: VMware Player: If you want to use Portable Update you can use this to install Windows inside a virtual machine to download the needed updates
  • NTLite: Integrates updates and creates ISO
  • Rufus: This tool will be used to create the bootable USB stick

Folder Structure

The folder structure should look like this:
 Explanation
  • IE11x64: If you want to integrate Internet Explorer 11 into your image the needed files will be put into this folder
  • Langpacks: Folder where you put your converted language packs .cab files
  • Langpacks_exe: Folder where you put your downloaded language packs .exe files
  • Updates: Folder where you put your update files
  • win7_pro_sp1_x64_en: Folder where you've unpacked your Windows 7 SP ISO
  • exe2cab.cmd: Small script which converts language pack exe files to cab files
  • exe2cab.exe: Tool to convert language pack exe files to cab files
  • langadd64-w7.cmd: Script which integrates language packs into your installer
  • win7_pro_sp1_x64_en.iso: The Windows 7 SP1 you've downloaded

Extract Windows ISO

Use 7-ZIP to extract the Windows ISO file into a subfolder (e.g. win7_pro_sp1_x64_en). If you want to be able to select the version (Starter, Home Basic, Home Premium, Professional, Ultimate) you have to delete the ei.cfg file which is located in the sources folder.

Integrating Language Packs

In the first step you have to download all the language packs you want to integrate into your Windows 7 installation. Put the downloaded language pack executables into the Langpacks_exe folder and then execute the following script (exe2cab.cmd) to convert the .exe to .cab files (unfortunately exe2cab.exe doesn't have a silent switch so you have to confirm each converted package:
 @echo off & setlocal enableextensions enabledelayedexpansion  
 set BASEDIR=%~dp0  
 set LANGPACKS=%BASEDIR%Langpacks  
 set LANGPACKS_EXE=%BASEDIR%Langpacks_exe  
 FOR /R %LANGPACKS_EXE% %%i IN (*.exe) DO (   
  %~dp0\exe2cab.exe %%i  
 )  
 move /Y %LANGPACKS_EXE%\*.cab %LANGPACKS%  

Caveat!: If you want to integrate a language which needs additional font packages then please read the note on the following page: Add a Language to Windows Setup

Create the following langadd64-w7.cmd in your base directory (make sure to adjust the SRC path to the path where you've extracted the Windows 7 SP1 installation files):
 @echo off & setlocal enableextensions enabledelayedexpansion  
 set BASEDIR=%~dp0  
 rem set paths to windows sources and language packs  
 set SRC=%BASEDIR%win7_pro_sp1_x64_en  
 set LANGPACKS=%BASEDIR%Langpacks  
 set MOUNT=%BASEDIR%Mount  
 set EXT=%BASEDIR%Extract  
 if exist "%MOUNT%" rd /s /q "%MOUNT%"  
 mkdir "%MOUNT%"
 echo "Integrate language packs to all editions"
 for /l %%e in (1, 1, 4) do (  
  echo "Mounting install.wim(%%e)"  
  "dism.exe" /mount-wim /wimfile:"%SRC%\sources\install.wim" /index:%%e /mountdir:"%MOUNT%"  
  FOR /F "usebackq" %%i IN (`dir /b "%LANGPACKS%"`) DO (   
   "dism.exe" /Image:"%MOUNT%" /Add-Package /PackagePath:"%LANGPACKS%\%%i"  
   "dism.exe" /Image:"%MOUNT%" /Gen-LangIni /Distribution:"%SRC%"  
  )  
  "dism.exe" /Image:"%MOUNT%" /Get-Packages /Format:Table  
  "dism.exe" /Image:"%MOUNT%" /Get-Intl  
  echo "Unmounting install.wim(%%e)"  
  "dism.exe" /unmount-wim /mountdir:"%MOUNT%" /commit  
 )  
 echo "Mounting boot.wim"  
 "dism.exe" /mount-wim /wimfile:"%SRC%\sources\boot.wim" /index:2 /mountdir:"%MOUNT%"  
 FOR /F "usebackq" %%i IN (`dir /b "%LANGPACKS%"`) DO (   
  if exist "%EXT%" rd /s /q "%EXT%"  
  mkdir "%EXT%"  
  echo "Extract %%i language pack"  
  expand "%LANGPACKS%\%%i" -f:* "%EXT%" > NUL  
  call :getlocale  
  echo "Copy language pack files to boot.wim and windows sources"  
  xcopy "%EXT%\setup\sources\*" "%SRC%\sources\" /cherkyi > NUL  
  xcopy "%EXT%\sources\license\*" "%SRC%\sources\license\" /cherkyi > NUL  
  xcopy "%EXT%\setup\sources\*" "%MOUNT%\sources" /cherkyi > NUL  
  xcopy "%EXT%\sources\license\*" "%MOUNT%\sources" /cherkyi > NUL  
 )  
 copy "%SRC%\sources\lang.ini" "%MOUNT%\sources\lang.ini" > NUL  
 echo "Unmounting boot.wim"  
 "dism.exe" /unmount-wim /mountdir:"%MOUNT%" /commit  
 rd /s /q "%MOUNT%"  
 rd /s /q "%EXT%"  
 echo End of language pack integration  
 pause  
 exit /b
  
 :getlocale  
 set currarea=  
 for /f "usebackq delims=" %%a in ("%EXT%\langcfg.ini") do (  
   set ln=%%a  
   if "x!ln:~0,1!"=="x[" (  
     set currarea=!ln!  
   ) else (  
     for /f "tokens=1,2 delims==" %%b in ("!ln!") do (  
       set currkey=%%b  
       set currval=%%c  
       if "x[LangInfo]"=="x!currarea!" if "xLanguage"=="x!currkey!" (  
         set LANG=!currval!  
       )  
     )  
   )  
 )  
 exit /b  
Open a command prompt with administrative rights and cd into the directory where you've place the  langadd64-w7.cmd script and the simply run the script which will take a while to complete (make sure dism can be found in the path or place dism.exe into the same folder where you've put langadd64-w7.cmd).

Downloading Windows Updates

Here two options are described for downloading the Windows updates. The advantages and disadvantages of each options is described in the Needed Tools section.

Windows Updates Downloader

Download the Windows Updates Downloader and the updates file for your Windows version and select the updates which you want to integrate and download the updates.

Portable Update

When you want to use the portable udpate tool you first have to install Windows inside a virtual machine. You can either use the original Windows 7 ISO if you don't want to integrate any language packs or use NTlite to create an ISO file:
  • Open NTLite and select Add and select the folder where you've extracted your installation files
  • Select Create ISO to create a new ISO file
Install Windows 7 inside a virtual machine using either this image file or the original ISO depending on wether you want or do not want to integrate language packs.

After you have finished installing it into the virtual machine you can enable shared folders to easily move files between the virtual machine and the host. Make sure you select the option Map as a network driver in Windows guests as this will make it easier for you to transfer the files.

Now download, extract and run Portable Update inside your virtual machine and download the available updates. When you look at the downloaded files you can see that there are .cab and .exe files in your folder:
  • Put all the files into the Updates folder
  • When you go to the Updates folder you will see that some are additional language pack files. In File Explorer select to show File Description and then move all language pack files into the Langpacks_exe folder

 Integrate Internet Explorer 11

 Extract the Internet Explorer installation file like this:
 ie11-windows6.1-x64-en-us_ddec9ddc256ffa7d97831af148f6cc45130c6857.exe /x:<project root>\IE11x64  


Integrate Updates And Drivers

Unfortunately not all updates can be integrated using NTLite. You can try to convert the executables using the exe2cab tool which will work for a few selected packages and some of those can than be integrated into the installer.

 For the next steps you need NTLite:
  • Add the folder where you've extracted your Windows installation files
  • Load the edition you want to modify: In the source list you will see the editions listed in the install.wim. Select the edition you want to modify and Load the image.
  • Go to the Updates tab and add the Updates folder (this is there folder where you have copied your update files) and then the IE11x64 (this is the folder where you have extracted the Internet Explorer 11 installation files) folder. NTLite will show you a warning that some updates can not be integrated. This is ok because not all updates can be slipstreamed.
  • Go to the Drivers tab and add the drivers you want to include
  • Go to the Apply tab and start the integration process. You can select to either keep only the selected edition (Export image selected) or keep all editions (Export image deselected)
  • If you want to keep the other editions then you have to repeat these steps for the other editions also

Create ISO

Use NTLite to create the ISO file. You can either select the image in the Image history in the Source tab and then select Create ISO or you can select Create ISO image on the Apply tab when you have loaded a .wim file.

Creating GPT Formated USB Stick 

You can create a bootable USB very easlily using the Rufus tool. Plug an USB stick into your computer and start Rufus. Make sure to select the USB stick as Device. If you want to install Windows 7 on an UEFI computer with a GPT formatted or empty disk select the GPT partition scheme for UEFI computer. If you're booting using the old BIOS method or use a MBR formated disk chose MBR partition scheme for BIOS or UEFI computers.
Select the ISO file which was created by NTLite and start the process.

Additional Informations

Unfortunately this is far from perfect. On my test installation there were still 61 Windows updates available after a fresh install. This is because it's not possible to automatically integrate the .exe files updates (e.g. .NET update) and some of the updates simply can't be integrated for whatever reason.

I have gathered the informations here from various places:
  • Raymond: Instructions on how to integrate Windows updates into installation sources
  • nextofwindows: Instructions on how to create UEFI bootable USB stick
  • Vistalizer: Instructions on how to convert the language EXE files to CAB files; script for integrating language pack
  • Good to Know Database: Script which integrates language packs into install sources
  • Technet: Instructions on how to integrate language pack into installations sources
  • Slipstream Internet Explorer 11: Tutorial for integrating Internet Explorer 11