Monday, January 13, 2020

Bash Script Runs From Terminal But Fails When Run From Anacrontab

The quick answer: Do not use an environmental variable in a bash script run from either cron or anacrontab.

I was developing a bash script to use tar to backup my files. In researching this, I ran across using the Linux environmental variable $SECONDS. Seemed pretty nifty as I could then get the elapsed time for the operation of the backup program.  My program worked well, as expected, when executed from the terminal, but failed when executed by anacrontab. In researching how to solve this problem, I ran across an old post that stated "If you run a script from cron make sure the script doesn't use any environment variables. Those variables are present when you are logged in as user X, but are not present when running from cron." This immediately  answered the question.

I was surprised though, at the number of posts asking for advise on how to resolve this type of problem but who did not not receive the answer above.

 I solved this issue by using the date command to set the start and end times. Then subtracting the values to get the elapsed time for the backup operation.
Also, I am sure that there are ways to use an environmental variable in either cron or anacrontab, but I did not want to delve into the issue further.

Saturday, November 23, 2019

Can't Access a Windows 10 Share From a Linux Computer Using Samba

I'm currently using Linux (Ubuntu 16.04) as my principle operating system. I also have one dual boot computer that can boot into Windows 10. Over the years, upgrades to both Linux and Windows have resulted in an inability to view shares and/or transfer between Linux and Windows. I've pretty much stamped-out any issues with accessing the computers running Linux from my computers when using Windows 10. However, on this last round of upgrades, I was unable to login to the computer operating under Windows 10 from my Linux computer. I was able to easily transfer files from the computer operating Windows to to the Linux computers. Today, I had some free time for looking into this issue. I believe that I have resolved it.
The solution is to set one of the Local Computer Policies to "Guest Only". See the image below. This solution found through trial and error. Note the line highlighted in blue.

 Note the text below (emphasis added):
"This security setting determines how network logons that use local accounts are authenticated. If this setting is set to Classic, network logons that use local account credentials authenticate by using those credentials. The Classic model allows fine control over access to resources. By using the Classic model, you can grant different types of access to different users for the same resource.
If this setting is set to Guest only, network logons that use local accounts are automatically mapped to the Guest account. By using the Guest model, you can have all users treated equally. All users authenticate as Guest, and they all receive the same level of access to a given resource, which can be either Read-only or Modify.

Default on domain computers: Classic.
Default on stand-alone computers: Guest only"
I do not have a local account credential (in short, no password). Once I switched "Network access: Sharing and security model for local account" to "Guest only", I was able to login to my computer running Windows 10.

Related to this is the fact that Microsoft depreciated SMBv1. This was not an issue related to my current post, but was an issue a while back, so I am posting the solution for how to restore  SMBv1. The following post by Microsoft was a useless dead-end, but it does provide some gobbledygook context. SMBv1 is not installed by default in Windows 10 Fall Creators Update and Windows Server, version 1709 and later versions.
The following post provides a solution on how to reactivate SMBv1 so that your Linux computer can access Samba shares on a Windows 10 computer. How to access files on network devices using SMBv1 on Windows 10.