Apple and Worms
Programming by accident
Qt 5.3.0 and mysql
Fixing up ACL
I went to a folder I owned, the folder had been created to store lots of C source files which I planned to use as a learning thing, I wanted to create some sub-folders and move various C src's into the appropriate folders eg: move the file (today.c) into the c-simple-start folder
[~/restart]$ mv today.c c-simple-start mv: rename today.c to c-simple-start/today.c: Permission denied [~/restart]$ ls -al c-simple-start total 0 drwxr-xr-x 2 dev staff 68 18 May 08:47 . drwxr-xr-x 83 dev staff 2822 18 May 08:47 ..
I have write permissions to the folder but get the Permission denied message. Looking at the permissions on the file:
[[~/restart]$ ls -al today.c -rw-r--r--+ 1 dev staff 144 19 Jan 2016 today.c
and I see the + symbol but what does that mean? Well ... it means that the file is under ACL control. How do do you find out? By reading man ls
From man ls :
-e Print the Access Control List (ACL) associated with the file,
if present, in long (-l) output.
Using ls with the l and e options shows:
[~/restart]$ ls -le
The + symbol in the permissions section shows that a folder (d1) and a file (getline) are under ACL control:
drwxr-xr-x+ 7 dev staff 238 8 Mar 2016 d1 0: group:everyone deny delete -rw-r--r-- 1 dev staff 15351 14 May 13:30 everyday.txt -rwxr-xr-x+ 1 dev staff 8976 19 Jan 2016 get-line 0: group:everyone deny delete
No one, (apart from an admin user) can modify the permissions:
[~/restart]$ mv today.c today-check-perm.c mv: rename today.c to today-check-perm.c: Permission denied [~/restart]$ ls -al today.c -rw-r--r--+ 1 dev staff 144 19 Jan 2016 today.c
this would fail so we need to sudo (see man chmod for detailed examples)
[~/restart]$ sudo chmod 664 today.c
remove ACL on all files in the current folder:
sudo chmod -N *
and to remove ACL recursively ie in all the folders below the current folder:
sudo chmod -R -N *
If using the terminal is not your first choice you can try the GUI approach via Get Info see OSXDaily Change PermissionsBack to top
Apples and Worms
I use an iMac, I have an iPhone and iPad and I think they are great bits of kit, mostly easy to use, have great softwares and lots of access to all of the things that a part-time developer like me likes to use but it seems things aren't always sweet in the baskets of Apple.
It is an old gag: you are about to take a bite of your lunch-time apple and a worm pops his head through the apple skin. Well there are apples and Apples and the latter have been known to have worms and such-like lurking beneath their shiny and colourful skins. For example: OS X versions prior to 10.10.3 contained a hidden API (a software tool) which could allow access to root privileges. The iPhone (and probably iPad) aren't exempted from such hidden nasties: it was reported that iPhones had a remote kill switch - your device could be wiped out by a loaded email. To their credit Apple have owned up to these curious practices and corrected them but it might leave users a little bit anxious about what else might be lurking under those glossy exteriors.
There is more on the upside. There is a plaint that Apple "systematically bans apps that endorse abortion rights or would help women find abortions". For me that is a great positive and I hope it is still the case and if it is then bless 'em! They can have their back-doors and hidden what-nots, decent users have nothing to hide and yours truly has no money.Back to top
Programming by accident
In computing terms I hail from the Jurassic era, I am a dinosaur. I mean of course that I am old and perhaps rare tho' not yet fossilized and of no interest to archaeologists. While I breath and my brain does not entirely sleep I cannot resist the urge to write programs, it is the opiate of the ageing nerd and I actually enjoy it. How old? The year of my first contact with computers is closer to the advent of the first electronic digital computer, Colossus of Bletchley Park fame, than now (March 2017) as I write this. The first stored program computer the Manchester Small-Scale Experimental Machine was built in Manchester in 1948 and ran its first program just 2 months after I was born also in Manchester at Ancoats Hospital. No, I don't think there is a connection, it's just a pleasant coincidence. You can see a video about MSSE here on youtube. You can see and hear a bunch of old codgers talk about their work of some seventy years ago. Without them and the many that followed you young (and us old) computer codgers couldn't do what we do today. Be thankful. If you don't like computers then you know who to blame. Be merciful.
I started in computing, after training in radar and radio electronics, as a hardware man, fixing hardware problems, software was a mystery to me and I was tempted to buy a second-hand PDP8 which was available for a few hundred dollars, the thing took up the space of a large office desk. I resisted. Around 1979 I first heard of microprocessors like the Intel 8008 and 8080. The 8080 was the first chip to be used with the popular CP/M operating system. In those early days to have 64 Kbytes of memory was to be "richer than Croesus" and disk space greater than 256k bytes was rare. My first disk drive was an 8 inch floppy disk drive with 256 Kbytes of storage.
After some years as a hardware man I started writing some almost serious software for microprocessor-based systems. My first real project was moderately complex and involved interfacing microprocessor-based systems with a Norcontrol radar simulator. The objective was to capture target data for a number of simulated ships radar systems and plot the tracks of the various ocean going vessels in the simulation exercise. I built a Z80 (a variant of the 8080 chip) single-board computer using wire-wrap, wrote what we now call a BIOS and burned it into a 2Kbyte EPROM, hooked this device into a serial link connecting two Nord 42 computers and captured the target data. This data was in a 16 bit floating point format which was converted into an 8 bit floating point format for yet another computer - a CP/M based machine - which did the actual plotting. All the plotting software was written in Fortran IV. From this point on my hardware interest in computing started to give way to an increasingly software bias.
Over the following years I have written all kinds of softwares: Accounting and other commercial applications, DBMS, building modelling, compilers, interpreters and, as we all do, what we now call web apps. The latter have been variously CGI using C++, much PHP/Mysql stuff and, for a while, Zope. All of this work was initially done on PCDOS and MSDOS machines, then Windows machines and latterly OSX and Linux.Back to top
Qt 5.3.0 and mysq
I'm not a Linux newbie but neither am I anything like an expert, I'm 66 years old so I should be expert at something but it's amazing how little I know. Strictly speaking how little I know of anything relevant to today's computing world. I've been involved in computing, in one way or another, since around 1974, and as old timers like to say "I've forgotten more than most people know". The corollary to this is I don't know much more than I've forgotten ... if you get my meaning, in other words I don't know much at all.
Over the last couple of days I've installed/built, reinstalled/rebuilt Qt 5.3.0 on my windows 7 box and my ubuntu 13.10, and I'm about to install it on my iMac (Mavericks). If you don't know what Qt is you can read more here. I've been using Qt since about version 4.7 and have written a couple of apps that are used in the wild. I rebuilt the apps on both machines and win7 was fine but ubuntu gave me problems with connections to a remote mysql database: apart from problems with accesss permissions, my apps couldn't find the mysql drivers so the apps couldn't connect. I had all the necessary packages but a key part couldn't be found, it looked like a missing Qt database driver but that didn't make sense since the Qt driver was where it ought to be: in the plugins/sqldrivers folder announcing itself as libqsqlmysql.so, ie a shared library. (It seems Linux has it's own version of dll hell). Anyway I found a neat tool called ldd which "ldd - print shared library dependencies" which is simpler but similar to the windows Dependency Walker (depends.exe) created by Steve Miller.
I looked in the plugins/sqldrivers folder and saw:
drwxr-xr-x 2 david david 4096 May 26 16:05 . drwxr-xr-x 21 david david 4096 May 26 16:05 .. -rwxr-xr-x 1 david david 784316 May 16 14:32 libqsqlite.so -rwxr-xr-x 1 david david 67964 May 16 14:32 libqsqlmysql.so -rwxr-xr-x 1 david david 80208 May 16 14:32 libqsqlpsql.so
Then ran ldd on libqsqlmysql.so (ldd libqsqlmysql.so). There was lots of stuff but the interesting point was:
libmysqlclient_r.so.16 => not found
So at least I now knew what the problem might be. The next step was to check on what mysql libs I did have:
locate libmysql /usr/lib/i386-linux-gnu/libmysqlclient.a /usr/lib/i386-linux-gnu/libmysqlclient.so /usr/lib/i386-linux-gnu/libmysqlclient.so.18 /usr/lib/i386-linux-gnu/libmysqlclient.so.18.0.0 /usr/lib/i386-linux-gnu/libmysqlclient_r.a /usr/lib/i386-linux-gnu/libmysqlclient_r.so /usr/lib/i386-linux-gnu/libmysqlclient_r.so.18 /usr/lib/i386-linux-gnu/libmysqlclient_r.so.18.0.0
There was lots of stuff shown but the key bits are above. The folder /usr/lib/i386-linux-gnu/ isn't in my $PATH and I don't know it's purpose but it confirmed that I did have the so's (dll's if you like), it was just libqsqlmysql.so in the plugins folder was pointing to a shared lib I didn't have. Well ... I didn't want to go "apt-getting" yet another and earlier library and decided to create a link from one I did have to the one I didn't have.
sudo ln -s /usr/lib/i386-linux-gnu/libmysqlclient.so.18.0 /usr/lib/libmysqlclient_r.so.16 sudo ln -s /usr/lib/i386-linux-gnu/libmysqlclient.so.18.0.0 /usr/lib/libmysqlclient_r.so.16.0.0
The versions were not that far apart so the chances are it would work and guess what ... it did. The apps were running and connecting to the remote mysql host. Later I learned (by reading man pages and things) that ldd is just a shell script and will, in some cases, attempt to execute the thing it's querying. This could be bad, very bad, if the object of ldd's enquiry is a dodgy piece of code. A better, and simpler, way is to use objdump
objdump -p libqsqlmysql.so | grep NEEDED
NEEDED libmysqlclient_r.so.16 NEEDED libQt5Sql.so.5 NEEDED libQt5Core.so.5 NEEDED libstdc++.so.6 NEEDED libc.so.6
I thought I'd check on the win7 box just to see if I could do the same as I had on linux. I have the Qt mingw32 installation and the clever and thoughtful fellows who built the mingw stuff for Qt have made a heap of tools available in the Tools\mingw482_32\bin directory and objdump is among them. In the win7 case the shared object is qsqlmysql.dll.
C:\Qt...\bin>objdump -p c:\Qt\Qt5.3.0\5.3\mingw482_32\plugins\sqldrivers\qsqlmysql.dll
will dump heaps of stuff about contents of the library but you can see the dependencies by grepping for "DLL Name". You can get grep and lots of other beaut utilities at the gnuwin32 project.
C:\Qt...\bin>objdump -p c:\Qt\Qt5.3.0\5.3\mingw482_32\plugins\sqldrivers\qsqlmysql.dll | grep "DLL Name" DLL Name: libgcc_s_dw2-1.dll DLL Name: KERNEL32.dll DLL Name: msvcrt.dll DLL Name: libstdc++-6.dll DLL Name: libmysql.dll DLL Name: Qt5Core.dll DLL Name: Qt5Sql.dll
or if you don't have grep use windows "find" :
C:\Qt...\bin>objdump -p c:\Qt\Qt5.3.0\5.3\mingw482_32\plugins\sqldrivers\qsqlmysql.dll | find "DLL Name" DLL Name: libgcc_s_dw2-1.dll DLL Name: KERNEL32.dll DLL Name: msvcrt.dll DLL Name: libstdc++-6.dll DLL Name: libmysql.dll DLL Name: Qt5Core.dll DLL Name: Qt5Sql.dll
The nearest equivalent command line on macOS that I could derive:
objdump -dylibs-used -macho Qt5.3.0/5.3/clang_64/plugins/sqldrivers/libqsqlmysql.dylib Qt5.3.0/5.3/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: libqsqlmysql.dylib ... /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib ... /usr/lib/libz.1.dylib ... /Users/dev/Qt5.3.0/5.3/clang_64/lib/QtSql.framework/Versions/5/QtSql ... /Users/dev/Qt5.3.0/5.3/clang_64/lib/QtCore.framework/Versions/5/QtCore ... /usr/lib/libstdc++.6.dylib ... /usr/lib/libSystem.B.dylib ...
but objdump has to be installed via source or homebrew or macports. Apple's otool is also available and gives the same result with fewer arguments:
$ otool -L Qt5.3.0/5.3/clang_64/plugins/sqldrivers/libqsqlmysql.dylib Qt5.3.0/5.3/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: libqsqlmysql.dylib ... /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib ... /usr/lib/libz.1.dylib ... /Users/dev/Qt5.3.0/5.3/clang_64/lib/QtSql.framework/Versions/5/QtSql ... /Users/dev/Qt5.3.0/5.3/clang_64/lib/QtCore.framework/Versions/5/QtCore ... /usr/lib/libstdc++.6.dylib ... /usr/lib/libSystem.B.dylib ...Back to top