Programmatically hiding many files when creating hybrid iso with hdiutil - macos

I'm trying to script the creation of a hyrbid (iso/joliet/hfs) iso with hdiutil. I can, for example, build an iso that hides things on the mac side like so:
hdiutil makehybrid -o foo.iso -hfs -joliet -iso -hide-hfs "{foo/bar.txt,foo/other.rtf}" foo
That's just an example of course, but the point is I can get it to hide say seven or eight example files I specify like that, with spaces in the filenames and verious dots and underscores.
But for my actual real-deal script I need to list in the neighborhood of 70 files, which does not seem to work when I test it. The whole string is being passed in correctly, I know this because when you turn on '-verbose' it prints the string and says it doesn't match anything.
So my best guess is it has something to do with the length of the string passed in, but I don't see anything in the docs indicating that. Any ideas? Think it's a bug? An alternative way of accomplishing this?
This is on Mac OS X 10.5.8, btw.

Two [UPDATE, make it Three] (untested) suggestions:
use the -plistin option to
specify all the parameters;
(better) try organizing the files to be
hidden into directories, if
necessary, so you can easily hide
them by directory-specific globs
rather than having to spell out each
file.
[UPDATE] you could try using mkisofs from cdrtools to make the ISO image. MacPorts has a supported port of it. It could be that the code in hdiutil was originally based on an earlier version. In any case, you have the advantage of access to the source code and perhaps figuring out what the limitations are.
P.S. There seems to be a couple of minor nits with the MacPorts port. In particular, the
man pages are installed in the wrong directory. [UPDATE: fixed in 3.00_1]

Related

How to find the Master Password on a Mac?

I have a master password set up on my mac, and I have forgotten it. I found the file path /etc/master.passwd though I am not sure if this is the right file. I do not want to reset the master password, only figure out what it is.
It is probably possible to try, especially if you recall something of the password. But it will take time to have the right tools and to do it, even weeks. Nobody can say that before trying. And some basic linux understanding is needed for the following instructions.
One of the best tool to try is this one http://www.openwall.com/john/doc/FAQ.shtml and you can find it in the KALI Linux distribution http://www.kali.org/
Once you upload your /etc/passwd and your master.passwd on KALI Linux, you can use unshadow to create a single file from the two (call it crackable.passwd) and then you can run
john --rules -w:/path/to/my/wordlist crackable.passwd
In a file called /path/to/my/wordlist you need to put as much words (newline separated) you can remember on your password. The --rules option does some mangling and permutations for you (on single words mostly, uppercase/lowercase, adding some numbers, adding special chars, etc...) but you might need to customize them. This is why I say it needs time to understand what you are doing.

renaming mass files from o to xxxx

I would like to rename multiple folders of files from
Blackmagic Cinema Camera_1_2013-12-06_2248_C0001_000000.dng
…
Blackmagic Cinema Camera_1_2013-12-06_2248_C0001_000322.dng
to
0.dng
…
322.dng
So in fact from 0 to xxxx (for safety get to 5 digits if necessary)
I am really new to the terminal tool (on mac osx 10.8) and cannot do the dumbest thing with it, I just know it's the most reliable way to do it, and as they are quite precious files for a project I'm not that keen on using a regular rename application that may do I don't know what slightly more than just rename those files, I just want them to be as pure as they are with the names changed.
So I read many stuff on here but as I know absolutely nothing about any command I can't interpret what was listed on the numerous topics on how to rename as they don't exactly apply to what I want to do. So if you could guys explain to me things as dumb as I am for it to be simple and comprehensible (what has to be explained, actually I just want something to work, not a class), would be great. This forum seems to have good answers quickly, seems all nice
Ah, btw, I would actually run that for a single file first (as a try) and after use it for all the folders of these like-named files. So it's like
Blackmagic Cinema Camera_1_2013-12-06_2321_C0005
…
Blackmagic Cinema Camera_1_2013-12-06_2327_C0000
for the folders names, each one containing a pile of files named like stated in the first part of this message. so i guess it would need something to apply to all folders of a chosen folder, as there are numerous ones.
(ah, when I say i'm the dumbest guy about it : I can understand, but just have no clue on this stuff, so if you could even tell me how to get to that file/folder/directory etc. whatever be needed to complete it for someone knowing 0)
Thanks in advance, very much !
From the directory containing your DNG files:
awk -F"[_.]" '$(NF) ~ /dng/ {system("mv "$0" "($(NF-1)+0)".dng");}' <(find .)
It worked for me in linux, and it should work in mac os too.
If you have any problem, just leave me a comment ;-)

How does man.cgi deal with cat vs. mdoc man pages?

I want to start a site with a collection of BSD man-pages, similar to man.cgi, but static HTML, and which includes all the stuff from the ports trees, too.
I've tried unpacking man/ from all the OpenBSD packages for a recent release, and I've noticed that although some packages provide mdoc pages, in man/man?/page.?, some others only provide terminal formatted pages in man/cat?/page.0.
I can use groff -mdoc -Thtml or mandoc -Txhtml for the mdoc files in man/man?/, but how do I convert the cat files from man/cat?/ into XHTML?
How do those man.cgi scripts at FreeBSD.org and NetBSD.org do this?
In MirBSD we’re delivering all online manpages as static HTML (the actual web CGI is thus very small), and use a crafty script to convert the output of nroff -Tcol foo.1 | col -x to XHTML/1.1 – although, for this to work, we had to tweak nroff(1) and the mdoc and man macropackages (and ms and me etc.) slightly. We only ship all manpages from base, as well as the historic BSD docs, though.
Also, GNU gnroff has no -Tcol, but -Tascii will work – but if you want to use this with gnroff output, you might need to change the regexps accordingly.
Be extra careful when editing this file: it contains normal UTF-8 stuff as well as extra control characters and invalid byte sequences; if you’re not careful, your editor will corrupt it. (I’m using jupp myself.)
For more live feedback on this, feel free to visit the MirBSD IRC channel.
As to your original goal: I suggest to only harvest manpages from binary packages, because they often get changed during compilation, such as by AC_SUBST in autoconf, or even only generated as part of the package build.

Rename file in Win32 to name with only differences in capitalization

Does anyone know a pure Win32 solution for renaming a file and only changing its capitalization, that does not involve intermediate renaming to a different name or special privileges (e.g. backup, restore).
Since the Win32 subsystem generally regards two file names differing only in capitalization as the same, I haven't been able to find any solution to the problem.
A test program I made with the MoveFile API seems to work. So does the rename command in cmd.exe. What have you tried, and what error are you getting?
This isn't relevant, but further testing shows that renaming a long filename in this way works but will change the short filename (alternating between ~1 and ~2 for example), incidentally.
Just use the normal MoveFile API. That call probably just turns into ZwSetInformationFile(..., FileRenameInformation,...) The docs for FILE_RENAME_INFORMATION states that you need DELETE access and the file can't be locked etc, but those restrictions will probably apply to other solutions also.
I do not believe there is a way to expose two files with identical names that differ only in spelling to the Win32 subsystem. Even if some how you were able to create these files, the most likely result would be that only one file would be accessible - defeating the purpose of staying soley in Win32.
If you want to go into the Native layer, you can create a file with NtCreateFile and InitializeObjectAttributes w/o OBJ_CASE_INSENSITIVE or you can pad the end with extra spaces (if you pad with extra spaces, the file will not be accessible from Win32 dos paths). See here: http://www.osronline.com/ddkx/kmarch/k109_66uq.htm . I'm pretty sure you were already aware but I included it incase you did not know.
So long as your file is not immediately needed by another program, you can use my solution.
When you rename the file, capitalize, and delete the last letter. Then rename again and return the letter.
:)

Are there any invalid linux filenames?

If I wanted to create a string which is guaranteed not to represent a filename, I could put one of the following characters in it on Windows:
\ / : * ? | < >
e.g.
this-is-a-filename.png
?this-is-not.png
Is there any way to identify a string as 'not possibly a file' on Linux?
There are almost no restrictions - apart from '/' and '\0', you're allowed to use anything. However, some people think it's not a good idea to allow this much flexibility.
An empty string is the only truly invalid path name on Linux, which may work for you if you need only one invalid name. You could also use a string like "///foo", which would not be a canonical path name, although it could refer to a file ("/foo"). Another possibility would be something like "/dev/null/foo", since /dev/null has a POSIX-defined non-directory meaning. If you only need strings that could not refer to a regular file you could use "/" or ".", since those are always directories.
Technically it's not invalid but files with dash(-) at the beginning of their name will put you in a lot of troubles. It's because it has conflicts with command arguments.
I personally find that a lot of the time the problem is not Linux but the applications one is using on Linux.
Take for example Amarok. Recently I noticed that certain artists I had copied from my Windows machine where not appearing in the library. I check and confirmed that the files were there and then I noticed that certain characters in the folder names (Named for the artist) were represented with a weird-looking square rather than an actual character.
In a shell terminal the filenames look even stranger: /Music/Albums/Einst$'\374'rzende\ Neubauten is an example of how strange.
While these files were definitely there, Amarok could not see them for some reason. I was able to use some shell trickery to rename them to sane versions which I could then re-name with ASCII-only characters using Musicbrainz Picard. Unfortunately, Picard was also unable to open the files until I renamed them, hence the need for a shell script.
Overall this a a tricky area and it seems to get very thorny if you are trying to synchronise a music collection between Windows and Linux wherein certain folder or file names contain funky characters.
The safest thing to do is stick to ASCII-only filenames.

Resources