Welcome to the new Woodmann RCE Messageboards Regroupment
Please be patient while the rest of the site is restored.

To all Members of the old RCE Forums:
In order to log in, it will be necessary to reset your forum login password ("I forgot my password") using the original email address you registered with. You will be sent an email with a link to reset your password for that member account.

The old vBulletin forum was converted to phpBB format, requiring the passwords to be reset. If this is a problem for some because of a forgotten email address, please feel free to re-register with a new username. We are happy to welcome old and new members back to the forums! Thanks.

All new accounts are manually activated before you can post. Any questions can be PM'ed to Kayaker.

Rotten apples

Post Reply
WaxfordSqueers
Senior Member
Posts: 1015
Joined: Tue Apr 06, 2004 11:00 am

Rotten apples

Post by WaxfordSqueers »

I presume this is off-topic. Trying to help a friend install a printer on the newest MacOS... Big Sur. Of course, Apple has gone mad and made it completely 64-bit and unable to run 32-bit apps. Naturally, the drivers for my friend's printer are 32-bit.

Not asking for help with the Mac but under the hood it's all ancient Unix. Wonder if anyone is proficient with Unix? I get the basic structure, having gone masochistic and tried to learn Linux version of Unix. Could never get past using ancient apps like Emacs. Never made sense to me, probably because Emacs was developed in the teletype era.

Apple has a mental problem with security. I am sure they wear at least 3 belts to hold up their pants and countless suspenders in case the belts should fail. Anytime on the MacOS I try to use the sudo command in Terminal, for root, I get asked for a password. I have noticed with my friend that if the Mac is left alone a for a few minutes, a logon is required to get the machine going again.

All I am trying to do is copy a couple of generic printer drivers from one directory to the other. If my users directory is in foo/users/downloads, I just want to use the cp command to copy the driver files to Users/Shared. If I do an ls -l command in Terminal, I can see the Shared directory under the same users directory as my foo/users directory but I cannot copy files between them. The macos file manager, Finder, seems absolutely useless for such minor copy routines since it won't even list the hidden shared folder under users.

I suspect I am doing something wrong like not using capitals in the right spot or trying to copy to a protected directory. Or, it's something really annoying abou the cp command.

I have tried cp -a ~/foo/users/downloads/*.* ~/users/shared Maybe I need to include foo in both, that just occured to me. However, when the cp command fails in macos it gives you nary a reason as to why. All it does is belch out command line values without an explanation of what each means. [/whine off].
User avatar
Kayaker
Posts: 4179
Joined: Thu Oct 26, 2000 11:00 am

Re: Rotten apples

Post by Kayaker »

Permissions suck. But if you're root you should be able to do anything. Maybe try copying the files in place, chown/chmod them and try copying that instead of the originals? Or test directory permissions and copy syntax on a simple text file you create.

As an aside, I usually like to cd to the directory I want to copy TO and use the "." character to copy "here", avoids having to write the <destination> directory and messing up the syntax.
copy -rp <source> .
WaxfordSqueers
Senior Member
Posts: 1015
Joined: Tue Apr 06, 2004 11:00 am

Re: Rotten apples

Post by WaxfordSqueers »

Kayaker wrote: Wed Jan 20, 2021 7:27 pm... if you're root you should be able to do anything.
Yeah...I've learned a lot since I posted. Know how to get root using sudo and beginning to find my way around the file system. Same as the Unix used on Linux except Mac tends to get choosy about what they'll let you see.

Have a version of Mac running on a VM so it limits me as far as connecting printers and testing Mac drivers. However, I figured out how to generate generic drivers and hopefully my friend's MacOS which is now purely 64-bit, will have the same features. Like Linux, Mac has sample drivers which are templates for generic drivers. You can use cups-driverd to generate a generic driver for several popular models. You can see them using lpinfo -m.

Also discovered that executables in the MacOS come with a bit set to prevent execution. chmod works for this as:
chmod +x ./foo where foo = filename.
Kayaker wrote: Wed Jan 20, 2021 7:27 pmAs an aside, I usually like to cd to the directory I want to copy TO and use the "." character to copy "here"
Great idea. I d/l'd an app for MacOS called mucommander. It's a dual-pane file manager that lets me drag files from Window to Window. Works on Linux as well, apparently.
WaxfordSqueers
Senior Member
Posts: 1015
Joined: Tue Apr 06, 2004 11:00 am

Re: Rotten apples

Post by WaxfordSqueers »

I've had to take a crash course in CUPS, the Common Unix Printer System. I managed to load a printer driver from the command line that worked but it's only in a MacOS Mojave version on a VM. Apparently, the latest MacOS, Big Sur, is pure 64-bit and unable to load 32 bit drivers.

I'm calling bs on that one. There is no reason why a 64 bit system could not run a 32 bit driver unless, of course, it is designed not to do that. I guess one major issue would be the memory addressable by a 32-bit system. Not sure how Microsoft pulls that off in the WOW system.

Apple has built in many protections against running apps that are not purchased through the App Store, one of them being sandboxes to cordon off certain parts of the OS. I understand that CUPS runs in a sandbox but in the CUPS config file there are provisions to 'relax' the sandbox, which I have yet to try on a real MacOS 64-bit system.

It's interesting that the current Apple CEO believes the future of Apple is in printers. That should read printer ink, where the real profits lie. HP has bent over backwards to prevent users using refilled ink cartridges and they have been cooperating with Apple by not supply drivers for certain printers. I have an HP with a LED readout and I have been checking under the hood. They know the serial numbers of cartridges and I'm sure that's what they check to see if the cartridge is HP or not. I am looking into a way to check the data being sent to the printer but I really need to get inside the printer electronics and interrogate the firmware.

Don't know if that would be a suitable topic for the reversing forum.
TBone
Senior Member
Posts: 139
Joined: Tue Mar 02, 2004 3:15 pm
Location: maze of twisty little passages, all alike

Re: Rotten apples

Post by TBone »

The differences between MacOS and Linux are relatively small. Linux is UNIX-like and MacOS X is literally UNIX apart from one or two minor versions that never got UNIX-03 certification for some reason or another. MacOS is even more similar to BSD, since the Mach kernel was originally developed as a replacement for the BSD kernel. As well, a lot of the userland tools in Mac are BSD-flavored.

If you're already familiar with FHS, and standard *NIX tools, you should feel relatively at home with Mac. For the most part, it's really just the UI layer that's proprietary. The bulk of the ring 0 stuff is actually open source, and the user-space CLI tools are basically just ports from BSD.

You should definitely install homebrew as well. If you've used apt, yum, choco, etc. it's basically the same thing. That will give you painless access to practically the entire OSS ecosystem. Nearly anything you might have used on Linux will be there, too. Stuff installed by homebrew lives in /usr/local/Cellar. The binaries are symlinked into /usr/local/(s)bin.
WaxfordSqueers wrote: Wed Jan 20, 2021 12:40 am However, when the cp command fails in macos it gives you nary a reason as to why. All it does is belch out command line values without an explanation of what each means.
Hm. That's certainly not how mine behaves. Ex. if I try to do:

Code: Select all

cp -q
I get:

Code: Select all

cp: illegal option -- q
usage: <etc>
Or if I try to copy a file that I don't have permissions to:

Code: Select all

cp: bar: Permission denied
If it's spitting usage at you, there's something wrong with your usage, and the first line of the output should identify the issue. I don't think there's any significant difference between cp on MacOs, BSD, or Linux.
WaxfordSqueers wrote: Wed Jan 20, 2021 12:40 am The macos file manager, Finder, seems absolutely useless for such minor copy routines since it won't even list the hidden shared folder under users.
This is pretty typical of graphical file managers on *NIX systems. You can toggle the display of hidden files with Cmd + shift + '.'

On that note:

Code: Select all

cp -a ~/foo/users/downloads/*.* ~/users/shared
Shell globbing is a bit different on *NIX than Windows because it isn't based on 8.3 file naming restrictions. The concept of a file extension is somewhat foreign to *NIX. The dot character is only special if it leads the file name. Otherwise it's just like any other character and occur as many times as you'd like (including not at all). So with *NIX shells, '*.*' will only match files that actually have a '.' in the name. What you probably want is merely '*'.

But by default, globbing excludes hidden files. So if you're trying to glob all the files in a directory, including hidden files, you'll need to override that behavior. How you do this depends on which shell you're running, but for zsh (the default now), you can either do this to make it a "global" glob:

Code: Select all

cp -a ~/foo/users/downloads/*(D) ~/users/shared
Or you can toggle the dotfile globbing behavior on and off with:

Code: Select all

setopt dotglob
cp -a ~/foo/users/downloads/* ~/users/shared
// Do some other things with dot globbing on
setopt dotglob off
Or you can live dangerously and just turn it on all the time by setting it on in your .zshrc

Either way, is this just a fictitious example? Because user homes should live in /Users. I would expect that what you really want to do is something more like:

Code: Select all

cp -ar /Users/foo/downloads/printer_driver_folder /Users/Shared/
So you'll wind up with /Users/Shared/printer_driver_folder which is an exact copy of the original folder. There's no shell globbing here, so hidden files are copied too.
WaxfordSqueers wrote: Thu Jan 21, 2021 6:18 am Also discovered that executables in the MacOS come with a bit set to prevent execution. chmod works for this as:
chmod +x ./foo where foo = filename.
That's just a vanilla UNIX thing. Or at least this is how bash and zsh are, anyway. Default permissions are 0777 (rwxrwxrwx) for directories, and 0666 (rw-rw-rw-) for files. Your umask is subtracted from that. If you download a binary from the internet, your browser is creating a new file, so the execute permission is not set. I don't know if there's a way to change this behavior. Maybe some obscure shell option. But it would generally be considered a Very Bad Idea(TM) for security reasons. Also for usability. If you're tab-completing a command name, it will only match against things that have the execute permission set.
WaxfordSqueers wrote: Tue Jan 26, 2021 5:12 pm I'm calling bs on that one. There is no reason why a 64 bit system could not run a 32 bit driver unless, of course, it is designed not to do that. I guess one major issue would be the memory addressable by a 32-bit system. Not sure how Microsoft pulls that off in the WOW system.
Well, I suppose you could, but it would cause a lot of headaches and limitations in the kernel. I'm not aware of any OS that lets you do this. WoW only lets you run 32-bit user mode code. 64-bit Windows and Linux both require 64-bit drivers/kernel modules.
Post Reply