<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def register_git_injector(username, password):
 """Generate a script that writes the password to the git command line tool"""

    fd, tmp_path = mkstemp()
    atexit.register(lambda: os.remove(tmp_path))

    with os.fdopen(fd, 'w') as f:
        f.write(ASKPASS.format(username=username, password=password or ''))

    chmod(tmp_path, 0o700)
    os.environ['GIT_ASKPASS'] = tmp_path