Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

Wednesday, April 27, 2016

Fortran 77 (F77) - How to Convert Integer to String and Concatenate

Recently was working with a 91-year old researcher on their Fortran 77 code written over the last 50-years. It needed debugging and some new coding so it lead to learning an ancient language lovingly called F77. It is an eye-opening experience to realize you are working on something with that much history and contributing to a legacy.

Anyhow, personal reflections aside, here is how you convert an integer into a string in fortran 77 and then concatenate it to another string. Useful for suffixing a filename for example.

Conversion

The basic idea behind converting a variable of any type to a string in Fortran 77 is to write that variable into a Character array variable of some length using the Write function. So in our case we will be writing an Integer into a Character array.

Note: The size of the character array should match the number of digits else you will have a lot of white space. Of course you can do that if you want.

Let's define two such variables and assign them values.

Tuesday, November 17, 2015

Linux SSHD: Per-User or Per-Group Configuration to Disable or Enable Functionality

To have configurations in sshd_config on a per-user or a per-group basis you need to use the Match Group and Match User directives.

Example

To prevent say remotely running GUI programs for all users save some you can use the following snippet. You can of course make other modifications.
# Disable X11 Forwarding and TCP Forwarding.
X11Forwarding no
AllowTcpForwarding no

# This to enable for a group called "X11AllowedList" that you created with 
# its respective members.
Match Group X11AllowedList
    X11Forwarding yes
    AllowTcpForwarding yes

## OR ##

# Or this to enable for a user specifically.
Match User johndoe
    X11Forwarding yes
    AllowTcpForwarding yes

Summary

The indentation is what makes this possible.
Match User johndoe
    X11Forwarding yes

Advanced: To Restrict Commands

If you want something more sophisticated than just preventing some GUI executions, you will want to create a restricted shell so that the users have limited access. This would then be force executed soon as someone logs in using the ForceCommand Directive as follows:
ForceCommand /usr/local/bin/strict_shell

Tuesday, October 2, 2012

GMail Tips: Manage Replied-to and Forwarded Message Workflow

Problem

Frequently, people want there to be some mechanism to know whether they have replied to messages in a conversation thread. Unfortunately, GMail does not have any mechanism for this by default.

Solution

However, using Labels and Filters a little creatively solves the issue mostly. Here are the filters I use for myself.

Replied
Matches: from:me subject:(Re:)
Do this: Apply label "↵", Never send it to Spam

Forwarded
Matches: from:me subject:(Fwd:)
Do this: Apply label "→", Never send it to Spam



Simple Steps to add filters to your GMail account:

  1. You can download my XML file with the filters here:
    1. Click here to get to it.
    2. Click on the "Download" button.

Friday, September 14, 2012

Overriding Shell for Users through SSSD

What is SSSD in a nutshell?

SSSD (System Security Services Daemon) is a collection of daemons used by Linux to manage the authentication and authorization to a system. In particular, it can interface with remote directories such as those that use LDAP (Lightweight Directory Access Protocol), and internally interfaces with NSS (Network Security Services) and PAM (Pluggable Authentication Module). Essentially, it can be configured to control the behaviour of these other services. You can learn more about it here:

https://fedorahosted.org/sssd/

The problem?

I was getting the authentication information from a central LDAP directory however, they only provided /bin/csh and the environment variable for the users while I needed it to be
/bin/bash in my environment.

Ideally, SSSD would have provided a way to override the shell in its configuration files, unfortunately, at the time of this writing that is only available in version 1.9 of SSSD which is currently in beta with the Fedora project. Further, my systems were Red Hat Enterprise Linux 6 (RHEL) which typically runs a few versions behind in most things though security patches and bug-fixes are backported.