Skip to main content

Posts

Showing posts with the label Linux

Update to Ubuntu 24.04

After years running Ubuntu 20.04, I recently (January 2025) installed Ubuntu 24.04 Noble Numbat. This cames with few improvements and a couple of disappointments, mainly the lost of my dual-screen: my graphic card, Nvidia Quadro FX3700, is not supported anymore by the latest driver. The result is: when the computer boots up, it does on output 0 (right screen). But as soon as Wayland starts, it switches to output 1 (left screen), ignoring the other output; my right screen remains black. This is a new behavior, it works fine on 20.04. Keyboard I write mainly in French and English. My keyboard is US Qwerty with US International layout. In English, what I see on keyboard is what I get on screen. In French, the diacritics are obtained with compositional keys: To get Ubuntu 20 Ubuntu 24 á é í ó ú ý Á É Í Ó Ú Ý ' e (Quote letter) ' E (Quote shift+letter) à è ...

SELinux: How to create a CIL from a TE file

For a project, I needed to compile and install a SELinux module only when necessary. Unfortunatelly, there is no versioning on stored modules; I can't check and compare with the source module. I came up with an idea: using MD5 signatures. Modules are stored in /var/lib/selinux/ Policy /active/modules/400/ ModuleName /cil The Policy can be found with sestatus : # sestatus SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted ... Stored modules are actually compressed CIL, which can easily been dumped with bzcat : # bzcat /var/lib/selinux/targeted/active/modules/400/my-httpd/cil (typeattributeset cil_gen_require httpd_t) (typeattributeset cil_gen_require default_t) (typeattributeset cil_gen_require sysstat_log_t) (typeattributeset cil_gen_require usr_t) (allow httpd_t usr_t (file (write create unlink setattr))) (allow httpd_t default_t (file (open re...

Ansible: summing the data disk space

The context On each host, I want to calculate the volume occupied by the OS and data disks. The OS is always installed on sda. The data disks are sdb, sdc, ... facter_disks provides info on the disks. I use the attribute size_bytes . The size of OS is easy to get: facter_disks.sda.size_bytes . However, it's less obvious to sum up the other disks since you don't know how many disks you have. Remember Ansible does not allow nested loops. Well, at least explicitely... The solution Extract sdb , sdc ,.. from facter_disks Convert it to a list Loop on this list to extract the path to attribute size_bytes Sum up the values (optional) Add the sum to facts - hosts: all gather_facts: true become: yes become_method: sudo ignore_errors: yes tasks: - set_fact: os_disk_total_size_gb: "{{facter_disks.sda.size_bytes/1073741824}}" data_disks_total_size_gb: "{{ facter_disks | map('regex_search'...

MOTU Midi Timepiece AV

I hooked up a MOTU Midi Timepiece AV to my Linux box. The context I've read there is no driver to use the MTP AV with Linux. Well, actually, there was one (mtpav.c) included with the package alsa-driver up to version 1.0.25. But, this package is now obsolete , embedded into the source of kernel. Since there is a driver for Windows, still available with ClockWork at MOTU site, I wanted to investigate the protocol (which is actually USB 1.1). Linux, Windows and Cubase SX Tools A computer running Linux and enough memory. Mine is HP XW6600, 8 cores, 16GB, running Ubuntu 20.04. A MOTU Midi Timepiece AV (MTP AV) USB compatible. Warning: there are 2 EPROM, one for Mac, one for Windows. Mine was the Mac version, but I installed the EPROM for Windows. ordered directly from MOTU website several years ago. The Windows driver for MTP AV USB MIDI Installer for Windows , available from MOTU site . Oracle Virtual Box, latest version (currently 6.1.18) and the Extensi...

MIDI for Linux

I want to drive MIDI with my Ubuntu. The context I play MIDI with Atari since 1986; at first a STF (1MB RAM), now a STe maxed to 4MB. Four megabytes of RAM may seems ridiculous by today's standards, but MIDI is extremely compact and use very few memory. Moreover, on the Atari, the operating system is in ROM, which limits the footprint on RAM to variables; hence, 4MB is actually plenty of room. The Atari has a built-in MIDI interface (1 In, 1 Out) driving 16 channels. However, in my case, 16 channels is not enough, so I purchased a MIDI interface (Soundpool MO4) which adds 4 outs, allowing to drive 80 channels. Unfortunately, 2-3 years ago, the MO4 has stopped working: still recognized by the Atari, but no output. Ok, well, this is another topic... In the past, I also got an old Toshiba Elite laptop running Windows XP. I tried to play MIDI with it. I first purchased a E-MU 2x2 interface (1 in, 1 out). Then I had the opportunity to buy a Midiman Midisport 4x4 (4 ins, 4 outs)...

Linux: the configuration folders

Configuration files Traditionally, Unix systems configuration were based on text files; you edit a file, sometime have to restart a service (rarely the entire system) and you’re in business. Most of the configuration files were located in the /etc folder. This paradigm is good when you have few servers to manage, but quickly becomes a hell above a dozen of servers: you have to manually edit the files which is error-prone and very time-consuming. Manual editing introduces differences between servers, proscribing the use of tool to help you. Configuration folders Linux authors suggested another approach: the configuration folders. The idea is simple: the main configuration file is only a skeleton with few parameters and commands to include files located in a folder (generally named xxx.d, in xxx is the configuration file). Apache users knows this paradigm for years. Examples: /etc/sudoers <-- main configuration file /etc/sudoers.d <-- configuration folder /etc/sudoer...

Ansible: How installing a group of packages?

Installing a set of packages with Ansible The context I need to install a group of packages on multiple Linux servers. Ansible is the right tool for that. The host file: hosts [test_machines]    test1.my_domain.com    test2.my_domain.com [dev]    dev1.my_domain.com    dev2.my_domain.com [uat]    uat1.my_domain.com    uat2.my_domain.com [prod]    prd1.my_domain.com    prd2.my_domain.com The playbook : add_packages.yml - hosts: all   vars_files:     - data/all_my_packages.yml   tasks:   - name: Ensure a set of packages is installed.     yum:       name={{ item.name }}       state={{ item.state }}     with_items: '{{ packages }}' The datafile: data/all_my_packages.yml packages:  - { name: 'glibc.i686', state: 'present' }  - { name: 'glibc.x86_64', state: 'present' ...

How to generate a MD5 hash

On Microsoft SQL Server SQL> SELECT HASHBYTES('MD5', source).... Source: varchar, nvarchar, ou varbinary, 8000 chars max. On Oracle PL/SQL> myhash := dbms_crypto.hash( source, dbms_crypto.HASH_MD5 ); SQL> select dbms_crypto.hash(utl_raw.cast_to_raw(source),2) ... Source: RAW, BLOB, et CLOB. With implicite conversion, you can also use CHAR, VARCHAR2, NCHAR, NVARCHAR2 et LONG. On Sybase sybase> SELECT HASHBYTES('MD5', source).... On MySQL mysql> SELECT MD5(source) ....

CGI & HTTP 500

I'am currently writing a small app in C that should display a timetable, on a Solaris 10/Apache Sun server. The app should open a HTML skeleton, syntaxicaly replace a couple of placeholders and display the content. If the skeleton could not be found, an HTML error message is sent back to the user. I compile, and test it: runs #1. I move my executable in the cgi-bin folder and invoke it with my browser and .. bang!: HTTP 500. The error_log shows: malformed header from script. Bad header=<HTML>: /apache/web/cgi-bin/timesheet.cgi The HTTP-500 arises mostly when Content-type:... is missing, or if there's not empty line before the text. However, in my case, when I invoked it manually: /apache/web/cgi-bin/timesheet.cgi .. it worked perfectly, displaying it could find its skeleton: Content-type: text/html <html> [... Error message ...] </html> So what was going on? I replaced the binary by a small script displaying the error message, hit it with my brower ... and it...

Continuous hiss on Fedora Core 3

On one of my machines, I run an out-of-the-box Fedora Core 3. One of the issues I had was a continuous hiss (white noise) on the speakers. Found on the net, here the solution: - go to Applications => Sound & Video => Volume Control - File => Change Device. If you have several devices, you should check on all. For my part, the noisy source came from "Ensoniq AudioPCI". - Edit => Preference. It opens "Volume Control Preferences". - Check-on "Capture"; the new source appears on the "Capture" tab. - You get the fellow; mute it and the noise instantaneously ceases.

vsftp: anomymous can upload but not download

This bug seems to be here from a long time. Even if a patch exists, the bug is still here in the most recent version. Here is the resolution (I assume gcc is installed): Stop your vsftpd daemon: service vsftpd stop Download the lastest source package (vsftpd-2.0.5 so far) from http://vsftpd.beasts.org . gunzip and untar # gunzip vsftpd-2.0.5.tar.gz # tar xf vsftpd-2.0.5.tar # cd vsftpd-2.0.5 A couple of files must be changed postlogin.c , line 1831 Replace ... if (p_sess->is_anonymous && tunable_chown_uploads) { vsf_sysutil_fchmod(new_file_fd, 0600); if (tunable_one_process_model) { ... by ... if (p_sess->is_anonymous && tunable_chown_uploads) { vsf_sysutil_fchmod(new_file_fd, (0666 & ~tunable_anon_umask)); if (tunable_one_process_model) { ... tunable.c , line 129,130 Replace /* -rw-rw-rw- */ unsigned int tunable_file_open_mode = 0666; by /* -rw------- */ unsigned int tunable_file_open_mode = 0600; builddefs.c , line 9 Replace ...

Linux and LDAP

The goal of this document is to explain how delegating the authentication mecanism for my Linux servers on a LDAP directory. Like many of you, our architecture also includes an Windows Active Directory server for the Windows workstation. To avoid having passwords both in AD and LDAP, they are only owned by AD; LDAP only have extra-info (groups user belongs to, and so on). This curious architecture is due to the fact our AD server belongs to a forest we don't manage. In turn, we have full control on the LDAP server. The main drawback of this specific architecture is to split identification and authentication; one is done on LDAP, the other on AD. Ok, now let's open the hood ... Every user must have a posixAccount object class. This object class contains the Unix specific information. You could use several tools to create this object class; personaly, I do it with simple openldap commands, wrapped in a small script: # ldapmodify -W -x -v -h $LDAP -D $CRED -a -f /tmp/posixAccount...

Samba: Clients get "system error 1223" (or 123) after a server reboot

Facts: a Linux+Samba server shares anonymously a folder. After a reboot, Win clients could not attach the share drive anymore. C:\>net use \\mylinux\folder Enter the user name for 'mylinux': System error 1223 has occurred. The operation was canceled by the user. C:\>net view \\mylinux\ System error 123 has occurred. The filename, directory name, or volume label syntax is incorrect. The process are present, and tcpdump doesn't provide much information. What's going on? After hours of headscratching, the light came: the firewall was on and no rules for the Samba protocol! Grrr!

Linux: ls takes forever on local volume

A strange issue, A simple ls on local volumes take forever to complete. Using strace gave a clue: # strace -fiqttvx ls -l /opt <snip> 10:26:37.917133 [002aa7a2] connect(4, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("142.216.0.1")}, 28) = 0 <snip> 10:26:47.912239 [002aa7a2] connect(4, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("142.216.0.1")}, 28) = 0 ... A socket on 142.216.0.1 is open and runs to timeout. Tcpdump gave more details: # tcpdump host 142.216.0.1 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes 10:26:30.356929 IP 142.216.47.158.33198 > 142.216.0.1.domain: ... 10:26:50.358702 IP 142.216.47.158.33199 > 142.216.0.1.domain: ... 10:26:50.358728 IP 142.216.47.158.33198 > 142.216.0.1.domain: ... ... The wanted port is "domain" (=53); that's a DNS request. Checking /etc/resolv.conf gave the answer...